[Haskell-cafe] A small (?) problem with type families
daniel.is.fischer at web.de
Fri Nov 13 16:00:28 EST 2009
Am Freitag 13 November 2009 21:36:59 schrieb David Menendez:
> On Fri, Nov 13, 2009 at 3:26 PM, Andy Gimblett <haskell at gimbo.org.uk> wrote:
> > First a type family where the type Y is functionally dependent on
> > the type X, and we have a function from Y to ().
> >> class X a where
> >> type Y a
> >> enact :: Y a -> ()
> This is ambiguous. Type families are not injective (that is, Y a ~ Y b
> does not imply a ~ b), so there's no way for the compiler to figure
> out which instance of X is being used when it encounters enact.
> Given these instances,
> instance X Int where
> type Y Int = Bool
> enact _ = ()
> instance X Char where
> type Y Char = Bool
> enact _ = undefined
> What is "enact False"?
> I recall seeing a discussion of this in the GHC documentation, but I
> can't seem to locate it.
Perhaps http://www.haskell.org/haskellwiki/GHC/Type_families#Frequently_asked_questions ?
More information about the Haskell-Cafe