This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| Example how OCaml's structurally typed modules can be combined and used. Note | |
| the overlap of [return] in [APPLICATIVE] and [MONAD] and how the signatures | |
| combine. | |
| *) | |
| let id x = x | |
| module type FUNCTOR = sig | |
| type 'a t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (** Modules sharing type constraint in functor. *) | |
| module type MONOID = sig | |
| type t | |
| val op : t -> t -> t | |
| val id : t | |
| end | |
| module type GROUP = sig | |
| include MONOID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* for OCaml <4.03.0 define: | |
| type ('a, 'b) result = Ok of 'a | Error of 'b *) | |
| module type MONAD = sig | |
| type 'a t | |
| val return : 'a -> 'a t | |
| val (>>=) : 'a t -> ('a -> 'b t) -> 'b t | |
| end | |
| module Id = struct |