[Haskell-cafe] Re: how would this be done? type classes? existential types?

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Fri Mar 17 10:46:56 EST 2006


Matthias Fischmann wrote:
> now i want to create a list of a type similar to
> 
>   [r1, r2, r3] :: (Resource a) => [a]
> 
> but with r1 being pizza, r2 being crude oil, and so on.

The type you actually want here is [exists a. (Resource a) && a], but no 
Haskell implementation supports that.

>   data Rs = forall a . (Resource a) => Rs a
>   unRs (Rs a) = a
>   rsName :: Rs -> String
>   rsName = resourceName . unRs
>   ...
> 
> [...]
> 
> but what is the type of unRs?

Its type is (Rs -> (exists a. (Resource a) && a)), but again no Haskell 
implementation supports that.

-- Ben



More information about the Haskell-Cafe mailing list