[Haskell-cafe] Beginners problem with the type system

Henrik Tramberend henrik.tramberend at fh-hannover.de
Tue Oct 23 04:13:07 EDT 2007


On 22. Oct 2007, at 20:16 , Stefan O'Rear wrote:

> This type signature means that 'port' is return type overloaded -  
> it can
> return ANY kind of port, and the caller gets to choose.  Which I don't
> think is what you want.

True.

> (Requires type family extension in GHC 6.8; an equivalent formulation
> using the older (2000) functional dependancies is possible)

Thanks for mentioning functional dependencies. I tied together the C  
and the P types like this:

 > class Channel c p | c -> p where
 >     port :: c a -> IO (p a)

 > data C a = C (P a)

 > instance Channel C P where
 >     port (C p) = return p

Which works nicely.

Thanks,
Henrik


More information about the Haskell-Cafe mailing list