Erasing that distinction enables some goodies such as first-class type constructors, which makes it possible to manipulate types of higher kind. This in turn, presumably enables things like Generalized Algebraic Data Types.
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.
With true typeclasses, there is no ambiguity which instance will be selected (there can only be one)
This distinction is often lost when comparing true type classes with their emulation via implicts.
Sometimes "more power" is not what you want i.e. this is more of a tradeoff.
So the OCaml implementation shouldn't make it any more difficult to discover which implicit is in use in a given context, because if an implicit is used, then it must necessarily be unique and there will be no ambiguity.
http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.htm...