Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 =
  sig
    type a
    type b
    type t = Pink of a | Blue of b

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

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
Francois.Pottier@inria.fr
http://pauillac.inria.fr/~fpottier/
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr