-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgeneric_util_sum.mli
More file actions
29 lines (23 loc) · 828 Bytes
/
Copy pathgeneric_util_sum.mli
File metadata and controls
29 lines (23 loc) · 828 Bytes
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
(** Empty and Sum datatypes. *)
open Generic_core
(** {2 Types} *)
(** Type with zero element. *)
type empty
(** Sum type. *)
type ('a, 'b) sum = Left of 'a | Right of 'b
(** Type witnesses for [empty] and [sum]. *)
type _ Ty.t +=
Empty : empty Ty.t
| Sum : 'a Ty.t * 'b Ty.t -> ('a, 'b) sum Ty.t
val left : 'a -> ('a,'b) sum
val right : 'b -> ('a,'b) sum
(** {2 Operations} *)
(** Empty elimination: anything can be proved from a
falsehood. It shouldn't be possible to execute that function
since we cannot give it any actual argument, however, the
function is useful when pattern matching requires some
impossible cases to be given anyway.
*)
val empty_elim : empty -> 'a
val either : ('a -> 'c) -> ('b -> 'c) -> ('a, 'b) sum -> 'c
val sum : ('a -> 'c) -> ('b -> 'd) -> ('a,'b) sum -> ('c,'d) sum