[ocaml] try a monad module type

This commit is contained in:
Julin S 2023-10-20 12:12:22 +05:30
parent afc3ca06bf
commit 7ed97ca479
2 changed files with 27 additions and 0 deletions

View File

@ -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

16
ocaml/monads.ml Normal file
View File

@ -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