caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Instanciating functor types with extra parameters
Date: Sat,  4 Aug 2007 21:13:32 +0200	[thread overview]
Message-ID: <1186254812.46b4cfdc2cef7@webmail.in-berlin.de> (raw)
In-Reply-To: <46B4A343.5030900@lix.polytechnique.fr>

Hello,


Zitat von Arnaud Spiwack <aspiwack@lix.polytechnique.fr>:

> Hi caml list !
>
> The recent, or rather current, thread on priority queues, raised back an
> issue that've I've been really infuriated with a couple of time the
> past, like, 2 years.
>
> When I have a functor type, like for example (not too innocent I'm afraid) :
>
> module type OrderedType =
>   sig
>     type t
>     val compare : t -> t -> int
>   end
>
>
> Something that naive intuition would allow you to do is something like :
>
> module GenOrder : OrderedType =
>   struct
>     type t = 'a
>     let compare = compare
>   end
[...]

I don't know if this is flexible/generic enough for you,
but at least for me it seems to be what you are looking for,
and it compiles:


===================================================
oliver@siouxsie2:~$ cat cmp.ml
module type OT2 =
  sig
    type 'a t
   val compare: 'a t -> 'a t -> int
  end


module GenOrder : OT2 =
  struct
    type 'a t = 'a
  let compare = compare
  end
oliver@siouxsie2:~$ ocamlc -i cmp.ml
module type OT2 = sig type 'a t val compare : 'a t -> 'a t -> int end
module GenOrder : OT2
oliver@siouxsie2:~$
===================================================


Ciao,
   Oliver


  parent reply	other threads:[~2007-08-04 19:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-04 16:03 Arnaud Spiwack
2007-08-04 16:15 ` [Caml-list] " Denis Bueno
2007-08-04 18:51 ` rossberg
2007-08-04 19:13 ` Oliver Bandel [this message]
2007-08-06 13:47 ` Mike Furr

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=1186254812.46b4cfdc2cef7@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --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).