Module Gitlab.Monad

All API requests are bound through this monad which encapsulates an Lwt cooperative thread and includes some state which may be set via API functions.

type 'a t

'a t is an Lwt thread sensitive to GitLab API state.

val return : 'a -> 'a t

return x is the value x wrapped in a state-sensitive Lwt thread.

val bind : ('a -> 'b t) -> 'a t -> 'b t

bind m f is the eventual value of f applied to the contents of m. Its argument order is designed for currying.

val map : ('a -> 'b) -> 'a t -> 'b t

map f m is bind m (fun x -> return (f x)). Its argument order is designed for currying.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

m >>= f is {!bind} f m.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

m >|= f is {!map} f m.

val (*>) : 'a t -> 'b t -> 'b t

m *> n is {m >>= fun _ -> n}.

val (>>~) : 'a Response.t t -> ('a -> 'b t) -> 'b t

m >>~ f is m >|= {!Response.value} >>= f.

val (>|~) : 'a Response.t t -> ('a -> 'b) -> 'b t

m >|~ f is m >|= {!Response.value} >|= f.

val catch : (unit -> 'a t) -> (exn -> 'a t) -> 'a t

catch try with is the result of trying try. If try succeeds, its result is returned. If try raises an exception, with is applied to the exception and the result of with is returned.

val fail : exn -> 'a t

fail exn raises exception exn inside of the monad.

val run : 'a t -> 'a Lwt.t

run m is the Lwt thread corresponding to the sequence of API actions represented by m. Once a t has been run, any GitLab API state such as associated default security tokens or declared user agent string will not be available in subsequently bound functions.

val embed : 'a Lwt.t -> 'a t

embed lwt is an Lwt thread lifted into the GitLab API monad. Its monadic state will be inherited from any monadic values bound before it.

val let+ : 'a t -> ('a -> 'b) -> 'b t
val and+ : 'a t -> 'b t -> ('a * 'b) t
val let* : 'a t -> ('a -> 'b t) -> 'b t
val and* : 'a t -> 'b t -> ('a * 'b) t