Skip to content
Snippets Groups Projects
Commit c1a32f17 authored by Valentin Perrelle's avatar Valentin Perrelle Committed by David Bühler
Browse files

[Eva] add bindings operators for Bottom

parent 6e6b6842
No related branches found
No related tags found
No related merge requests found
......@@ -25,16 +25,23 @@ module Type = struct
type 'a or_bottom = [ `Value of 'a | `Bottom ]
(* This monad propagates the `Bottom value if needed. *)
let (>>-) t f = match t with
| `Bottom -> `Bottom
| `Value t -> f t
(* Use this monad if the following function returns a simple value. *)
let (>>-:) t f = match t with
| `Bottom -> `Bottom
| `Value t -> `Value (f t)
let zip x y =
match x, y with
| `Bottom, _ | _, `Bottom -> `Bottom
| `Value x, `Value y -> `Value (x,y)
let (let+) = (>>-:)
let (and+) = zip
let (let*) = (>>-)
let (and*) = zip
end
include Type
......
......@@ -33,6 +33,13 @@ module Type : sig
(** Use this monad if the following function returns a simple value. *)
val (>>-:) : 'a or_bottom -> ('a -> 'b) -> 'b or_bottom
(* Binding operators, applicative syntax *)
val (let+) : 'a or_bottom -> ('a -> 'b) -> 'b or_bottom
val (and+) : 'a or_bottom -> 'b or_bottom -> ('a * 'b) or_bottom
(* Binding operators, monad syntax *)
val (let*) : 'a or_bottom -> ('a -> 'b or_bottom) -> 'b or_bottom
val (and*) : 'a or_bottom -> 'b or_bottom -> ('a * 'b) or_bottom
end
include module type of Type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment