Existential types: want better syntactic support (autoboxing?)

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Jan 31 05:12:03 EST 2006

On Mon, 2006-01-30 at 18:20 -0800, John Meacham wrote:
> so if I understand this proposal properly, it would mean the following
> every single parameter type class whole parameter is of kind * 
> class Foo a where
> automatically declares a data type defined as
> data Foo = exists a . Foo a => Foo_ a   
> (where Foo_ is some internal, non user accessable name)
> and an instance
> instance Foo Foo where
>         method (Foo_ x) = method x 
>         ...
> this all seems quite nice, I really like it, we can always determine
> whether a name is a class or type from context (I think the only reason
> the namespaces are combined is due to import/export lists)
> the only issue is the autoboxing. we can't introduce an actual
> constructor because constructors are in a different namespace. so we
> would need to automatically turn anything of type Foo a => a into a Foo
> when it is used as such.

Is that really necessary (or desirable)?

As it was suggested in the thread on existential types it probably wants
to be made explicit when you throw away type information by putting
something behind an interface.

How about just making the conversion "Foo a => a -> Foo" explicit? And
of course the conversion is just the constructor Foo.


More information about the Haskell-prime mailing list