c-cube/ocaml-containers

Functor for monadic support in cases of wrong arity

bluddy opened this issue · 1 comments

The MONAD interface requires a type with arity 1 : 'a t.
This is fine for modules that have precisely that type arity. Result is not that way, instead having an arity of 2.
In order to support monadic operations over Result, we want to create another functor within Result that specializes away the error type. We can call this functor something like MonadMake. All this functor needs is the functions for return and bind.

I don't see how this functor would work; operations taking a MONAD already require only return and >>=, so a functor doesn't bring anything to the table compared to:

module M = struct
  type 'a t = ('a, foo) result
  let return = CCResult.ok
  let (>>=) = CCResult.(>>=)
end

Please re-open if I missed something :)