caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Default methods for module signatures
@ 2014-02-05 18:49 Yotam Barnoy
  2014-02-05 19:43 ` Martin Jambon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yotam Barnoy @ 2014-02-05 18:49 UTC (permalink / raw)
  To: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1636 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-05 21:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-05 18:49 [Caml-list] Default methods for module signatures Yotam Barnoy
2014-02-05 19:43 ` Martin Jambon
2014-02-05 20:03   ` Yotam Barnoy
2014-02-05 20:10   ` Martin Jambon
2014-02-05 19:53 ` Pippijn van Steenhoven
2014-02-05 20:29 ` Alain Frisch
2014-02-05 21:17   ` Yotam Barnoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).