Browse thread
Strategy to avoid name collision in signatures
-
michael.le_barbier@l...
- Andrej Bauer
-
Julien Moutinho
- michael.le_barbier@l...
[
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: | michael.le_barbier@l... |
| Subject: | Re: [Caml-list] Strategy to avoid name collision in signatures |
Julien Moutinho <julien.moutinho@gmail.com> writes:
> I'm not sure if it could be of some help, but here is another scheme
> wherein the functor <name>Type.Make does not include its argument PROTO,
> so that there is no namespace conflict with type t.
> However the PROTO structure can no longer be used anonymously:
This is fine. Here's how I will work it out:
module Ordered =
struct
module type PROTO =
type t
val compare: t -> t -> int
end
module type S =
type t
val compare: t -> t -> int
val ge: t -> t -> bool
end
module Macro (P:PROTO) =
struct
let ge x y = (compare x y) >= 0
end
module Make (P:PROTO) =
struct
type t = P.t
include Macro(P)
end
end
It seems as economic as possible, provided I want to provide both the
`Macro' and `Make' version. Thanks for the hint!
--
Cordialement,
Michaël LB