File: monad.mli

package info (click to toggle)
xen-api-libs 0.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,940 kB
  • sloc: ml: 13,925; sh: 2,930; ansic: 1,699; makefile: 1,240; python: 83
file content (70 lines) | stat: -rw-r--r-- 1,713 bytes parent folder | download
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 : sig

	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 : functor (B : BASE) ->
	sig
		type 'a m = 'a B.m
		val ( >>= ) : 'a m -> ('a -> 'b m) -> 'b m
		val bind : 'a m -> ('a -> 'b m) -> 'b m
		val return : 'a -> 'a m
	end

end

(** 2-parameter monads. *)
module M2 : sig

	module type BASE =
	sig
		type ('a, 'b) m
		val bind : ('a, 'b) m -> ('a -> ('c, 'b) m) -> ('c, 'b) m
		val return : 'a -> ('a, 'b) m
	end

	module type MONAD =
	sig
		type ('a, 'b) m
		val ( >>= ) : ('a, 'b) m -> ('a -> ('c, 'b) m) -> ('c, 'b) m
		val bind : ('a, 'b) m -> ('a -> ('c, 'b) m) -> ('c, 'b) m
		val return : 'a -> ('a, 'b) m
	end

	module Make : functor (B : BASE) ->
	sig
		type ('a, 'b) m = ('a, 'b) B.m
		val ( >>= ) : ('a, 'b) m -> ('a -> ('c, 'b) m) -> ('c, 'b) m
		val bind : ('a, 'b) m -> ('a -> ('c, 'b) m) -> ('c, 'b) m
		val return : 'a -> ('a, 'b) m
	end

end