Module Sugar__Promise_builder

How to create a promise-based result monad:


  module MyError = struct
    type t = A | B | C
  end

  module MyMonad = struct
    type 'a t = 'a Lwt.t
    let return = Lwt.return
    let (>>=) = Lwt.(>>=)
  end

  module MyResult = Sugar.Promise.Make (MyError) (MyMonad)
  

Notice that for most cases, you can just plug the module directly from a monadic library, like:


    module MyResult = Sugar.Promise.Make (MyError) (Lwt)
    module MyResult2 = Sugar.Promise.Make (MyError) (Async.Std.Deferred)
  
module Make : functor (UserError : Sugar.S.Params.Error) -> functor (UserMonad : Sugar.S.Params.Monad) -> Sugar.S.Promise with type error := UserError.t and type monad := a UserMonad.t and type 'a value = ('aUserError.t) Result.result and type 'a result = ('aUserError.t) Result.result UserMonad.t

A parametric module that implements the monadic interface for values. The complete documentation can be found in Sugar.S.Promise.