English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Strategy to avoid name collision in signatures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-04 (07:29)
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 =

  module type PROTO =
    type t
    val compare: t -> t -> int

  module type S =
    type t
    val compare: t -> t -> int
    val ge: t -> t -> bool

  module Macro (P:PROTO) =
    let ge x y = (compare x y) >= 0

  module Make (P:PROTO) =
    type t = P.t
    include Macro(P)


It seems as economic as possible, provided I want to provide both the
`Macro' and `Make' version. Thanks for the hint!
Michaël LB