Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
Compiler feature - useful or not?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Compiler feature - useful or not?
On Fri, 16 Nov 2007, Martin Jambon wrote:

> On Fri, 16 Nov 2007, Alain Frisch wrote:
>
>>  Martin Jambon wrote:
>> >   You can write
>> >     match (x : Priv_int.t) with 0 -> true | _ -> false
>>
>>  Actually, you cannot do that, at least with private types as implemented
>>  in OCaml's CVS. And this is to be expected given the lack of implicit
>>  subsumption in OCaml. If you were able to do such a thing, what type
>>  schema would you give to:
>>
>>   let f = function 0 -> true | _ -> false
>>
>>  ?
>
> Using the notation for polymorphic variant types:
>
> val f : [< int ] -> bool
>
> Type [> int ] would be the same as [ int ] or int.

Please don't take my suggestions too seriously, but it could be cool to 
define types such as:

type bit = [ 0 | 1 ]


Martin

--
http://wink.com/profile/mjambon
http://martin.jambon.free.fr