caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jonathan Roewen" <jonathan.roewen@gmail.com>
To: "Martin Hofmann" <mhofmann@tcs.ifi.lmu.de>
Cc: caml-list@inria.fr, Oliver.Friedmann@web.de
Subject: Re: [Caml-list] Modules within classes
Date: Wed, 13 Sep 2006 20:10:17 +1200	[thread overview]
Message-ID: <ad8cfe7e0609130110m3f6da7bbu89bda2d1566025b3@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0609130924310.29369@orvieto.tcs.ifi.lmu.de>

It's the same at normal scope:

type t = 'a;; doesn't compile.

you need: type 'a t = 'a, which isn't compatible with input type for Set.

I think the Set module is intentionally monomorphic...

Jonathan

On 9/13/06, Martin Hofmann <mhofmann@tcs.ifi.lmu.de> wrote:
> Dear all,
>
> Can someone explain what is wrong here and perhaps suggest a workaround?
>
> class ['a] test ( l : 'a list) =
> object
>   method result =
>     let module M =
>      struct
>        type t = 'a
>        let compare x y =
>          if x < y then -1 else if x > y then 1 else 0
>      end
>  in
>    let module MSet = Set.Make(M)
>    in  MSet.elements (List.fold_right MSet.add l MSet.empty)
> end;;
>
> OCaml says: "Unbound type parameter 'a".
>
> Our aim is of course not to program sorting the umpteenth time but to
> have a means for using Pervasives.Set within a parametrised class.
>
> The problem seems to be that although "class ['a]" binds 'a its use is
> nevertheless disallowed in the scope of the class declaration.
>
> Many thanks in advance!
>
> Martin Hofmann (on behalf of Oliver Friedmann)
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  reply	other threads:[~2006-09-13  8:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-13  7:44 Martin Hofmann
2006-09-13  8:10 ` Jonathan Roewen [this message]
2006-09-13  9:48   ` [Caml-list] " Jonathan Roewen
2006-09-13  9:36 ` Pietro Abate

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=ad8cfe7e0609130110m3f6da7bbu89bda2d1566025b3@mail.gmail.com \
    --to=jonathan.roewen@gmail.com \
    --cc=Oliver.Friedmann@web.de \
    --cc=caml-list@inria.fr \
    --cc=mhofmann@tcs.ifi.lmu.de \
    /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).