Browse thread
Instanciating functor types with extra parameters
-
Arnaud Spiwack
- Denis Bueno
- rossberg@p...
- Oliver Bandel
- Mike Furr
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oliver Bandel <oliver@f...> |
| Subject: | Re: [Caml-list] Instanciating functor types with extra parameters |
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