caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pippijn van Steenhoven <pip88nl@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Default methods for module signatures
Date: Wed, 5 Feb 2014 20:53:52 +0100	[thread overview]
Message-ID: <20140205195352.GS13040@xinutec.org> (raw)
In-Reply-To: <CAN6ygO=F1VMSEB1QoBv8U+f0QgQk3wA4RTrc91gnV4f5Gwc9QA@mail.gmail.com>

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

Hi Yotam,

The way I usually do this is by making a minimal required subset module
type and then a default module that includes the overrides:

  module DefaultMonad(M :
    sig
      type 'a m
      val return : 'a -> 'a m
      val (>>=) : 'a m -> ('a -> 'b m) -> 'b m
    end) : Monad with type 'a m = 'a M.m =
  struct
    open M (* for >>= *)
    let (>>) m f = m >>= λ _ → f
    include M (* fill in the signature and possibly override above
                 definition *)
  end

Then you can pass your incomplete module (without >>) to DefaultMonad,
which implements a default for you, which you can still override in a
complete module.

Regards,
Pippijn

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-02-05 19:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 18:49 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 [this message]
2014-02-05 20:29 ` Alain Frisch
2014-02-05 21:17   ` Yotam Barnoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140205195352.GS13040@xinutec.org \
    --to=pip88nl@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).