[GHC] #14782: typeclass polymorphism defeats bang patterns
GHC
ghc-devs at haskell.org
Fri Feb 9 08:44:41 UTC 2018
#14782: typeclass polymorphism defeats bang patterns
-------------------------------------+-------------------------------------
Reporter: dmwit | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I think the following program should crash, but it doesn't:
{{{
{-# LANGUAGE BangPatterns #-}
main = let n :: Num a => a; !n = undefined in return ()
}}}
Interestingly, my attempt to translate this out of BangPatterns into
standard Haskell according to the translation on the wiki page led to a
compile-time error:
{{{
main = let n :: Num a => a; x at n = undefined in x `seq` return ()
}}}
Produces the error:
{{{
test.hs:1:12: error:
• Overloaded signature conflicts with monomorphism restriction
n :: forall a. Num a => a
• In the expression:
let
n :: Num a => a
x at n = undefined
in x `seq` return ()
In an equation for ‘main’:
main
= let
n :: Num a => a
x at n = undefined
in x `seq` return ()
|
1 | main = let n :: Num a => a; x at n = undefined in x `seq` return ()
| ^^^^^^^^^^^^^^^
}}}
Even giving `x` its own explicitly polymorphic type signature -- what I
thought was the standard way to prevent the monomorphism restriction from
being a problem -- doesn't help. I'm uncertain what to make of that, but
it certainly seems related: earlier versions of the compiler both do not
give that error and do produce a crashing program, as I expected.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14782>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list