
#14368: GHC 8.2.1 doesn't inform you when the monomorphism restriction kicks in anymore -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Poor/confusing Unknown/Multiple | error message Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This program doesn't typecheck due to the monomorphism restriction: {{{#!hs f = (==) }}} In GHC 8.0.2, the error message was quite helpful in informing you of this fact: {{{ GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:1:1: error: • Ambiguous type variable ‘a0’ arising from a use of ‘==’ prevents the constraint ‘(Eq a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance Eq Ordering -- Defined in ‘GHC.Classes’ instance Eq Integer -- Defined in ‘integer-gmp-1.0.0.1:GHC.Integer.Type’ instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’ ...plus 22 others ...plus 7 instances involving out-of-scope types (use -fprint-potential-instances to see them all) • When instantiating ‘f’, initially inferred to have this overly-general type: forall a. Eq a => a -> a -> Bool NB: This instantiation can be caused by the monomorphism restriction. }}} Notice the `NB: This instantiation can be caused by the monomorphism restriction` part. But in GHC 8.2.1, this advice has mysteriously vanished! {{{ GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:1:5: error: • Ambiguous type variable ‘a0’ arising from a use of ‘==’ prevents the constraint ‘(Eq a0)’ from being solved. Relevant bindings include f :: a0 -> a0 -> Bool (bound at Bug.hs:1:1) Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance Eq Ordering -- Defined in ‘GHC.Classes’ instance Eq Integer -- Defined in ‘integer-gmp-1.0.1.0:GHC.Integer.Type’ instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’ ...plus 22 others ...plus 9 instances involving out-of-scope types (use -fprint-potential-instances to see them all) • In the expression: (==) In an equation for ‘f’: f = (==) | 1 | f = (==) | ^^^^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14368 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler