package spotlib

  1. Overview
  2. Docs

Build a full Monad interface of data type with 2 parameters, T2, from the minimum specification of S2. Note that it only builds functions. The type is not exported.

Parameters

module M : S2

Signature

include T2 with type ('a, 'z) t := ('a, 'z) M.t
val return : 'a -> ('a, 'z) M.t
val bind : ('a, 'z) M.t -> ('a -> ('b, 'z) M.t) -> ('b, 'z) M.t
val fmap : ('a -> 'b) -> ('a, 'z) M.t -> ('b, 'z) M.t

fmap in Haskell

val liftM : ('a -> 'b) -> ('a, 'z) M.t -> ('b, 'z) M.t

Synonym of fmap

val fmap2 : ('a -> 'b -> 'c) -> ('a, 'z) M.t -> ('b, 'z) M.t -> ('c, 'z) M.t

fmap2 in Haskell

val liftM2 : ('a -> 'b -> 'c) -> ('a, 'z) M.t -> ('b, 'z) M.t -> ('c, 'z) M.t

synonym of fmap2 in Haskell

val void : ('a, 'z) M.t -> (unit, 'z) M.t
val seq : ('a, 'z) M.t list -> ('a list, 'z) M.t

sequence in Haskell. Not tail recursive.

val seq_ : (unit, 'z) M.t list -> (unit, 'z) M.t

sequence_ in Haskell. Not tail recursive.

val mapM : ('a -> ('b, 'z) M.t) -> 'a list -> ('b list, 'z) M.t

Not tail recursive by default

val mapM_ : ('a -> (unit, 'z) M.t) -> 'a list -> (unit, 'z) M.t

Not tail recursive by default

val iteri : (int -> 'a -> (unit, 'z) M.t) -> 'a list -> (unit, 'z) M.t

Iteration with index starting from 0. Not tail recursive by default.

val for_ : int -> int -> (int -> (unit, 'z) M.t) -> (unit, 'z) M.t

for like iteration. Not tail recursive by default

val join : (('a, 'z) M.t, 'z) M.t -> ('a, 'z) M.t
val prod : ('a, 'z) M.t -> ('b, 'z) M.t -> ('a * 'b, 'z) M.t
module Infix : Infix2 with type ('a, 'z) t := ('a, 'z) M.t
module Syntax : Syntax2 with type ('a, 'z) t := ('a, 'z) M.t
OCaml

Innovation. Community. Security.