Version française
Home     About     Download     Resources     Contact us    
Browse thread
Union of polymorphic variants...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Stephane Glondu <steph@g...>
Subject: Re: [Caml-list] Union of polymorphic variants...
Jacques GARRIGUE a écrit :
> Nothing is "difficult". But not everything is well-defined...
> The question is where do we start, where do we stop.
> 
> type a = [`S of a | `Z]
> 
> should #a be (`S _ | `Z) or (`S (`S _ | `Z) | `Z) or ...?

OK, I grasp now the difficulty of the problem.

> Note that you can still build the types by hand
> 
> type 'a t = [`A of 'a]
> type b = [`B of bool]
> type c = [`C of char]
> type a = [b|c] t
> 
> let f = function
>     `A #b as x -> fb x
>   | `A #c as x -> fc x

I didn't know this trick.


Thanks,

-- 
Stéphane Glondu