Existential types: want better syntactic support (autoboxing?)

John Meacham john at repetae.net
Mon Jan 30 21:20:53 EST 2006


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.

it should be possible, but the exact changes to typechecking needed
might be subtle..

an alternative might be to just allow existential types in structures so
we can have [exists a . Foo a => a], but that probably has its own can
of worms...

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell-prime mailing list