Missing constant folding for Numeric.Natural
The following Haskell code
module Zero where
import Numeric.Natural
zero :: Natural
zero = 0
generates this Core:
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
zero1
zero1 = 0
-- RHS size: {terms: 39, types: 12, coercions: 0, joins: 0/0}
zero
zero
= case zero1 of {
S# i#_a2c6 ->
case tagToEnum# (>=# i#_a2c6 0#) of {
False -> underflowError;
True -> NatS# (int2Word# i#_a2c6)
};
Jp# dt_a2cg ->
case uncheckedIShiftRL# (sizeofByteArray# dt_a2cg) 3# of {
__DEFAULT ->
case sizeofByteArray# dt_a2cg of {
__DEFAULT -> NatJ# dt_a2cg;
0# -> underflowError
};
1# ->
case indexWordArray# dt_a2cg 0# of wild2_a2ck { __DEFAULT ->
NatS# wild2_a2ck
}
};
Jn# ipv_a2cn -> underflowError
}
It should instead generate this:
zero = NatS# 0##
This kind of code is generated whenever one uses GHC.TypeLits.natVal
, even at a constant Nat
.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |