|
|
|
|
|
by platz
4070 days ago
|
|
the monad example in 1ML is: type MONAD (m : type ⇒ type) =
{
return a : a → m a;
bind a b : m a → (a → m b) → m b
};
map a b (m : type ⇒ type) (M : MONAD m) (f : a → b) (mx : m a) =
M.bind a b mx (fun (x : a) ⇒ M.return b (f x)) (* : m b *)
not too bad.. though I wonder if things are defined structurally instead of nominally, which monad instance are you going to get for a given expression. Haskell's "one instance per class" rule means the compiler figure out which monad instance to apply.This looks more flexible, but also looks like it will require more annotations and explicit parameters. |
|