id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,testcase,blockedby,blocking,related,differential
8931,The type defaulting in GHCi with Typeable,skata,,"
The type defaulting in GHCi works in less cases with GHC 7.8.1-rc2 than with older versions, though there is no change in the related part of the documentation (i.e., ""2.4.7 Type defaulting in GHCi"").
{{{
skata@kata58:~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.0.20140228
skata@kata58:~$ ghci
GHCi, version 7.8.0.20140228: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m +Data.Typeable
Prelude Data.Typeable> let {f :: Read a => (a->Bool) -> Char; f = undefined}
Prelude Data.Typeable> f (\x -> (x == 3))
*** Exception: Prelude.undefined <== This is the expected result.
Prelude Data.Typeable> let {f :: Typeable a => (a->Bool) -> Char; f = undefined}
Prelude Data.Typeable> f (\x -> (x == 3)) <== Type defaulting does not work in this case.
:6:1:
No instance for (Typeable a0) arising from a use of ‘f’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance [overlap ok] Typeable ()
-- Defined in ‘Data.Typeable.Internal’
instance [overlap ok] Typeable Bool
-- Defined in ‘Data.Typeable.Internal’
instance [overlap ok] Typeable Char
-- Defined in ‘Data.Typeable.Internal’
...plus 14 others
In the expression: f (\ x -> (x == 3))
In an equation for ‘it’: it = f (\ x -> (x == 3))
:6:13:
No instance for (Eq a0) arising from a use of ‘==’
The type variable ‘a0’ is ambiguous
Relevant bindings include x :: a0 (bound at :6:5)
Note: there are several potential instances:
instance Eq a => Eq (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’
instance Eq Integer -- Defined in ‘integer-gmp:GHC.Integer.Type’
instance Eq () -- Defined in ‘GHC.Classes’
...plus 33 others
In the expression: (x == 3)
In the first argument of ‘f’, namely ‘(\ x -> (x == 3))’
In the expression: f (\ x -> (x == 3))
:6:16:
No instance for (Num a0) arising from the literal ‘3’
The type variable ‘a0’ is ambiguous
Relevant bindings include x :: a0 (bound at :6:5)
Note: there are several potential instances:
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in ‘GHC.Real’
...plus 7 others
In the second argument of ‘(==)’, namely ‘3’
In the expression: (x == 3)
In the first argument of ‘f’, namely ‘(\ x -> (x == 3))’
}}}
On the other hand,
{{{
skata@kata58:~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1
skata@kata58:~$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m +Data.Typeable
Prelude Data.Typeable> let {f :: Read a => (a->Bool) -> Char; f = undefined}
Prelude Data.Typeable> f (\x -> (x == 3))
*** Exception: Prelude.undefined
Prelude Data.Typeable> let {f :: Typeable a => (a->Bool) -> Char; f = undefined}
Prelude Data.Typeable> f (\x -> (x == 3))
*** Exception: Prelude.undefined
}}}
I think the old behavior is compliant with the documentation.
",bug,closed,normal,7.8.1,Compiler (Type checker),7.8.1-rc2,fixed,"type defaulting, Typeable",,Unknown/Multiple,Unknown/Multiple,GHC rejects valid program,ghci/scripts/T8931,,,,