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 Monad_intf.S2 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
include Monad_intf.EX2 with type ('a, 'z) t := ('a, '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

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

Not tail recursive

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

Iteration with index starting from 0. Not tail recursive.

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

for like iteration. Not tail recursive

val join : (('a, 'z) M.t, 'z) M.t -> ('a, 'z) M.t
include Monad_intf.Infix2 with type ('a, 'z) t := ('a, 'z) M.t
val (>>=) : ('a, 'z) M.t -> ('a -> ('b, 'z) M.t) -> ('b, 'z) M.t

synonym of bind

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

synonum of fmap, with the flipped arguments

Applicative style binops

val (^<$>) : ('a -> 'b) -> ('a, 'z) M.t -> ('b, 'z) M.t

same as map, <$> in Haskell

val (/<*>) : ('a -> 'b, 'z) M.t -> ('a, 'z) M.t -> ('b, 'z) M.t

<*> in Haskell

module S : Monad_intf.S2 with type ('a, 'z) t := ('a, 'z) M.t
module EX : Monad_intf.EX2 with type ('a, 'z) t := ('a, 'z) M.t
module Infix : Monad_intf.Infix2 with type ('a, 'z) t := ('a, 'z) M.t
OCaml

Innovation. Community. Security.