1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
(*
* Copyright (C) 2010-2011 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
(** 1-parameter monads. *)
module M1 = struct
module type BASE =
sig
type 'a m
val bind : 'a m -> ('a -> 'b m) -> 'b m
val return : 'a -> 'a m
end
module type MONAD =
sig
type 'a m
val (>>=) : 'a m -> ('a -> 'b m) -> 'b m
val bind : 'a m -> ('a -> 'b m) -> 'b m
val return : 'a -> 'a m
end
module Make (B : BASE) : MONAD with type 'a m = 'a B.m =
struct
type 'a m = 'a B.m
let (>>=) = B.bind
let bind = B.bind
let return = B.return
end
end
(** 2-parameter monads. *)
module M2 = struct
module type BASE =
sig
type ('a, 'x) m
val bind : ('a, 'x) m -> ('a -> ('b, 'x) m) -> ('b, 'x) m
val return : 'a -> ('a, 'x) m
end
module type MONAD =
sig
type ('a, 'x) m
val (>>=) : ('a, 'x) m -> ('a -> ('b, 'x) m) -> ('b, 'x) m
val bind : ('a, 'x) m -> ('a -> ('b, 'x) m) -> ('b, 'x) m
val return : 'a -> ('a, 'x) m
end
module Make (B : BASE) : MONAD with type ('a, 'x) m = ('a, 'x) B.m =
struct
type ('a, 'x) m = ('a, 'x) B.m
let (>>=) = B.bind
let bind = B.bind
let return = B.return
end
end
|