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
[Caml-list] weak type variables in module type declarations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-05-28 (08:04)
From: Francois Pottier <Francois.Pottier@i...>
Subject: Re: [Caml-list] weak type variables in module type declarations

Dear Tyng-Ruey,

Weak type variables are not allowed to appear in declared signatures,
because there would be no good way of defining their meaning.

Instead of

> 	module type SUM =
> 	sig
> 	  type ('a, 'b) t = Pink of 'a | Blue of 'b
> 	  val pair : ('_a -> ('_a, '_b) t) * ('_a -> ('_a, '_b) t)
> 	end

how about trying

  module type SUM =
    type a
    type b
    type t = Pink of a | Blue of b

    val pair: (a -> t) * (a -> t)

Then, you can use, say,

  SUM with type a = int
       and type b = bool

in a context where you know that a and b should be instantiated to
int and bool, respectively.

François Pottier
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr