[GHC] #8931: The type defaulting in GHCi with Typeable

#8931: The type defaulting in GHCi with Typeable -------------------------------------+------------------------------------- Reporter: skata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Operating System: Unknown/Multiple Keywords: type defaulting, | Type of failure: GHC rejects Typeable | valid program Architecture: Unknown/Multiple | Test Case: Difficulty: Unknown | Blocking: Blocked By: | Related Tickets: | -------------------------------------+------------------------------------- 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. <interactive>: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)) <interactive>: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 <interactive>: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)) <interactive>: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 <interactive>: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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8931 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8931: The type defaulting in GHCi with Typeable
-------------------------------------+-------------------------------------
Reporter: skata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.8.1-rc2
checker) | Keywords: type defaulting,
Resolution: | Typeable
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: GHC rejects | Difficulty: Unknown
valid program | Blocked By:
Test Case: | Related Tickets:
Blocking: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#8931: The type defaulting in GHCi with Typeable
-------------------------------------+-------------------------------------
Reporter: skata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.8.1-rc2
checker) | Keywords: type defaulting,
Resolution: | Typeable
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: GHC rejects | Difficulty: Unknown
valid program | Blocked By:
Test Case: | Related Tickets:
Blocking: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#8931: The type defaulting in GHCi with Typeable -------------------------------------+------------------------------------- Reporter: skata | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: type defaulting, Resolution: | Typeable Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: GHC rejects | Difficulty: Unknown valid program | Blocked By: Test Case: | Related Tickets: ghci/scripts/T8931 | Blocking: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => ghci/scripts/T8931 Comment: Thanks for pointing this out. Pls merge if convenient. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8931#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8931: The type defaulting in GHCi with Typeable -------------------------------------+------------------------------------- Reporter: skata | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: type defaulting, Resolution: fixed | Typeable Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: GHC rejects | Difficulty: Unknown valid program | Blocked By: Test Case: | Related Tickets: ghci/scripts/T8931 | Blocking: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed * milestone: => 7.8.1 Comment: Merged, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8931#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC