[ocaml] try a monad module type
This commit is contained in:
parent
afc3ca06bf
commit
7ed97ca479
|
@ -0,0 +1,11 @@
|
|||
-I /media/julinusername/eins/gits/math-comp/mathcomp
|
||||
-R /media/julinusername/eins/gits/math-comp/mathcomp mathcomp
|
||||
|
||||
-arg -w -arg -projection-no-head-constant
|
||||
-arg -w -arg -redundant-canonical-projection
|
||||
-arg -w -arg -notation-overridden
|
||||
-arg -w -arg +duplicate-clear
|
||||
-arg -w -arg +non-primitive-record
|
||||
-arg -w -arg +undeclared-scope
|
||||
-arg -w -arg +deprecated-hint-rewrite-without-locality
|
||||
-arg -w -arg -elpi.add-const-for-axiom-or-sectionvar
|
|
@ -0,0 +1,16 @@
|
|||
(* https://cs3110.github.io/textbook/chapters/ds/monads.html *)
|
||||
|
||||
module type Monad = sig
|
||||
type 'a t
|
||||
val return: 'a -> 'a t
|
||||
val (>>=): 'a t -> ('a -> 'b t) -> 'b t
|
||||
end
|
||||
|
||||
module Maybe : Monad = struct
|
||||
type 'a t = 'a option
|
||||
let return a = Some a
|
||||
let (>>=) a f =
|
||||
match a with
|
||||
| None -> None
|
||||
| Some a' -> f a'
|
||||
end
|
Loading…
Reference in New Issue