Qcheck_extra.Monad
Monad
extends the Applicative
type class with a new function join
. join
takes a value in a nested context a t t
and joins them together so that we have a single context a t
.
We can define let*
in terms of join
and vice versa:
let ( let* ) x f = join (map f x)
let join x =
let* y = x in
y
assuming
( let* ) = bind
.
A Monad
should satisfy:
(f >=> g) >=> h = f >=> (g >=> h)
return >=> f = f = f >=> return
assuming
( let* ) = bind
.
and
f >=> g =
fun x ->
let* y = f x in
let* z = g y in
return z