diff options
author | David Feuer <david.feuer@gmail.com> | 2018-02-19 23:48:22 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-02-19 23:53:17 -0500 |
commit | 517c194095064c123b18b779c96c0866e0b3a6d9 (patch) | |
tree | 0d808d002dd4296206334d300c7e1eef21527b68 /compiler/prelude/PrelRules.hs | |
parent | eb2daa2b6a83412382aa0fcda598f8b3d40fde2c (diff) | |
download | haskell-517c194095064c123b18b779c96c0866e0b3a6d9.tar.gz |
Document missing dataToTag# . tagToEnum# rule
Explain why we don't have a rule to optimize `dataToTag# (tagToEnum# x)`
to `x`.
[skip ci]
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #14282
Differential Revision: https://phabricator.haskell.org/D4375
Diffstat (limited to 'compiler/prelude/PrelRules.hs')
-rw-r--r-- | compiler/prelude/PrelRules.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs index c9a3bc78aa..73484b7c35 100644 --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -909,6 +909,19 @@ dataToTagRule = a `mplus` b guard $ ty1 `eqType` ty2 return tag + -- Why don't we simplify tagToEnum# (dataToTag# x) to x? We would + -- like to, but it seems tricky. See #14282. The trouble is that + -- we never actually see tagToEnum# (dataToTag# x). Because dataToTag# + -- is can_fail, this expression is immediately transformed into + -- + -- case dataToTag# @T x of wild + -- { __DEFAULT -> tagToEnum# @T wild } + -- + -- and wild has no unfolding. Simon Peyton Jones speculates one way around + -- might be to arrange to give unfoldings to case binders of CONLIKE + -- applications and mark dataToTag# CONLIKE, but he doubts it's really + -- worth the trouble. + -- dataToTag (K e1 e2) ==> tag-of K -- This also works (via exprIsConApp_maybe) for -- dataToTag x |