id summary reporter owner description type status priority milestone component version resolution keywords cc os architecture failure testcase blockedby blocking related differential
2418 desugaring type function application to constraint makes bug disappear claus "When considering type functions, I find it helpful to desugar their applications into additional constraints (`tf a` becomes `tf a~tfa=>tfa`). But consider this example from a recent [http://www.haskell.org/pipermail/haskell-cafe/2008-July/044911.html haskell-cafe thread]:
{{{
{-# OPTIONS_GHC -fglasgow-exts #-}
class Blah f a where blah :: a -> T f f a
class A f where type T f :: (* -> *) -> * -> *
-- wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a
wrapper :: forall a f . (Blah f a) => a -> T f f a
wrapper x = blah x
}}}
for which `GHCi, version 6.9.20080514` yields:
{{{
C:\Documents and Settings\cr3\Desktop\TF.hs:8:12:
Could not deduce (Blah f a) from the context (Blah f1 a)
arising from a use of `blah'
at C:\Documents and Settings\cr3\Desktop\TF.hs:8:12-17
Possible fix:
add (Blah f a) to the context of the type signature for `wrapper'
In the expression: blah x
In the definition of `wrapper': wrapper x = blah x
C:\Documents and Settings\cr3\Desktop\TF.hs:8:12:
Couldn't match expected type `T f1 f1 a'
against inferred type `T f f a'
In the expression: blah x
In the definition of `wrapper': wrapper x = blah x
Failed, modules loaded: none.
}}}
Switching to the desugared version of the `wrapper` signature makes the error go away, so the ""desugared"" and original version are not equivalent in the current implementation of type families! See also [http://www.haskell.org/pipermail/haskell-cafe/2008-July/044914.html].
For added fun, GHCi reports the sugared type when using the desugared one:
{{{
*Main> :t wrapper
wrapper :: (Blah f a) => a -> T f f a
}}}
" bug closed normal 6.10.1 Compiler (Type checker) 6.9 duplicate type families Unknown/Multiple Unknown/Multiple