caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Phantom types and polymorphic variants
@ 2005-01-27  0:00 Daniel Bünzli
  2005-01-27  0:59 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Bünzli @ 2005-01-27  0:00 UTC (permalink / raw)
  To: caml-list

Hello,

Suppose I have the following (well-typed) definitions

> type tool = [`Spoon | `Fork]
>
> type 'a t = unit constraint 'a = [< tool]
>
> type 'a toolspec = unit constraint 'a = [< tool]
>
> let spoon : [< tool > `Spoon ] toolspec = ()
> let fork : [< tool > `Fork ] toolspec = ()
>
> let create : ([< tool ] as 'a) -> 'a t = fun t -> ()
> let create' : ([< tool ] as 'a) toolspec -> 'a t = fun t -> ()

I don't really understand why the type of the value returned by create 
and create' differ :

> # create `Spoon;;
> - : [< Test.tool > `Spoon ] Test.t = ()
> # create' spoon;;
> - : [< Test.tool ] Test.t = ()

I expected the second value to have the same type as the first.

Thanks for your explanations,

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-27  0:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27  0:00 Phantom types and polymorphic variants Daniel Bünzli
2005-01-27  0:59 ` [Caml-list] " Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).