This file contains 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
// Functor interface. | |
type Functor<'F> = { map : ('T -> 'U) -> 'F<'T> -> 'F<'U> } | |
// Monad interface. | |
type Monad<'M> = { | |
return : 'T -> 'M<'T> | |
join : 'M<'M<'T>> -> 'M<'T> | |
} | |
// Monad "library" (operations over monads). |
This file contains 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
(* General functor signature. *) | |
module type FUNCTOR = sig | |
type 'a t | |
val map : ('a -> 'b) -> 'a t -> 'b t | |
end | |
(* General def of catamorphism module, parameterized by a functor *) | |
module Cata (F : FUNCTOR) = struct | |
type 'a t = 'a F.t |
This file contains 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
(* Functors and modular implicits | |
* opam switch 4.02.0+modular-implicits | |
* eval `opam config env` | |
*) | |
module type FUNCTOR = sig | |
type 'a t | |
val map : ('a -> 'b) -> 'a t -> 'b t | |
end | |
let map {F : FUNCTOR} = F.map |
OlderNewer