Very nice proposal. I'm not crazy about the word 'virtual' since it doesn't really mean anything (and has been brutally abused in C++), but that's obviously a minor nitpick. Any reason this patch wasn't picked up?

-Yotam


On Wed, Feb 5, 2014 at 3:29 PM, Alain Frisch <alain@frisch.fr> wrote:
I proposed (13 years ago...) a small patch to support optional fields in modules.  This would help achieving the desired effect. See:

http://alain.frisch.fr/info/patch-option-announce
http://alain.frisch.fr/info/patch-option

-- Alain



On 2/5/2014 7:49 PM, Yotam Barnoy wrote:
Hello List

I would like the following feature, and I'm not enough of an expert in
module-fu to know if something like this is doable.

Suppose I have a module signature of

module type Monad = sig
   type 'a m
   val return : 'a -> 'a m
   val (>>=) : 'a m -> ('a -> 'b m) -> 'b m
   val (>>) : 'a m -> 'b m -> 'b m
end

I would like to have a default implementation for (>>), since a simple
default implementation is

let (>>) m f = m >>= fun _ -> f

Alternatively, I would like to include this from some DefaultMonad
module, but have the (>>=) referred to in the function be my newly
defined (>>=) implementation (ie. late binding). Is there currently any
way to do this? If not, would there be a way to implement a partial
default implementation built into or associated with a module signature?
Something like

module type Monad = sig... default struct... end

Haskell has this available as part of the semantics of their typeclass
system, and I think it would be really handy to have (if there isn't
already a way to do it currently).

-Yotam




--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs