Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] opaque polymorphism
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-11 (19:17)
From: Brian Rogoff <bpr@b...>
Subject: Re: [Caml-list] Re: Phantom types (very long)
On Tue, 11 Sep 2001, j h woodyatt wrote:
> So okay... I take it back.  Caml *does* have invariants.  (I'm
> learning.  Slowly.  But I'm learning.)
> This "phantom types" design pattern is one I have never seen before.

I remember reading J. Vouillon's post a long time ago and thinking "Man,
that's weird, having that type parameter not show up on the right hand
side of the type definition!" But it wasn't until Blume's post on the ML
ng that I got a name for the concept "phantom" and "witness" types. Do a
Google search on "phantom type" and you'll turn up a few Haskell paper's,
most notably tsome ones on connecting Haskell to Microsoft COM, and some
on domain specific languages.

> It doesn't seem to be used in the standard library anywhere I can see.  It
> looks like it might be useful in presenting a safer network programming
> interface than the low-level wrappers around BSD sockets (which I've
> never liked).

It's always a good idea to have thin (low level bindings) available. You
can build your abstractions on top of them, but to do otherwise is an
abstraction inversion.

> Are there any other mind-blowingly elegant design patterns lurking in
> the corners of the Caml type inference engine that I should know about?

Yes! And there there will be even more when we get polymorphic recursion
and generics ;-)

-- Brian

PS: Yeah, I'll post some more soon assuming I don't get blown up. Many
tricks involve simulating dependent types so if you look up dependent
types that'll get you started. In particular try to understand Danvy's
"Functional Unparsing"" paper.

Bug reports:  FAQ:
To unsubscribe, mail  Archives: