[Haskell-cafe] Type families vs. functional dependencies -- how to express something

Tomáš Janoušek tomi at nomi.cz
Fri May 21 07:34:58 EDT 2010


Hello,

On Tue, May 18, 2010 at 04:47:50PM -0700, Dan Weston wrote:
> > Unifying those two types by hand, I get:
> >
> >     P (A t -> B a)
> > ~>  P (B a)
>
> Maybe the problem is that type families (and associated types, their  
> class cousins) are not injective: P x ~ P y does not imply that x ~ y.  
> Maybe you need a data type (with appropriate wrapping and unwrapping) to  
> ensure injectivity. Cf:
>
> http://www.haskell.org/haskellwiki/GHC/Type_families#Injectivity.2C_type_inference.2C_and_ambiguity
> http://www.mail-archive.com/haskell-cafe@haskell.org/msg63359.html

That's probably it, thanks. I think I'll just stay with functional
dependencies this time, a data type with wrapping and unwrapping can't
possibly make the code more readable :-).

Regards,
-- 
Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/


More information about the Haskell-Cafe mailing list