Require bang-patterns for unlifted bindings
GHC allows let/where bindings for unlifted values, but they are necessarily strict. That does lead to confusing behaviour. For example, 'f' and 'g' behave differently here:
{-# LANGUAGE MagicHash #-}
import GHC.Base
import GHC.Exts
main :: IO ()
main = do print (I# (f 5# 0#))
print (I# (g 4# 0#))
f :: Int# -> Int# -> Int#
f x y | False = x `divInt#` y
f x y = x
g :: Int# -> Int# -> Int#
g x y | False = z
where z = x `divInt#` y
g x y = x
Suggestion: require that an unlifted let/where binding has a bang on it. That would make lifted and unlifted bindings behave uniformly.
Simon
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |