Re: Type constraints

From: Didier Rousseau (Didier.Rousseau@cnam.fr)
Date: Fri May 30 1997 - 11:24:21 MET DST


Date: Fri, 30 May 1997 11:24:21 +0200
From: Didier Rousseau <Didier.Rousseau@cnam.fr>
To: mposada@impsat.net.co
Subject: Re: Type constraints

bonjour a tous,

Ernesto Posse wrote:
>
> [My apologies for not including a French Version]
>
> Hello. I have the folowing problem. I need to define some interrelated
> types as follows:
>
> type 'a node = {x: 'a; y: t1}
> and t1 = A | B of t1*t1
> and t2 = C | D of (string * t2) node
>
> The interpreter prints the inferred type:
>
> type 'a node = { x: 'a; y: t1 } constraint 'a = string * t2
> type t1 = | A | B of t1 * t1
> type t2 = | C | D of (string * t2) node
> ...

une solution est de declarer :

type 'a node = {x: 'a; y: t1}
and t1 = A | B of t1*t1
;;

type t2 = C | D of (string * t2) node | E of bool node
;;

Didier Rousseau



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET