[commit: ghc] : getIdFromTrivialExpr_maybe: Return dataConWorkId for nullary data cons (75e5dd9)

git at git.haskell.org git at git.haskell.org
Mon Oct 10 21:43:28 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : 
Link       : http://ghc.haskell.org/trac/ghc/changeset/75e5dd948dc4c3db6830383b5cc83231a71005d6/ghc

>---------------------------------------------------------------

commit 75e5dd948dc4c3db6830383b5cc83231a71005d6
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Sun Oct 9 13:44:00 2016 -0400

    getIdFromTrivialExpr_maybe: Return dataConWorkId for nullary data cons


>---------------------------------------------------------------

75e5dd948dc4c3db6830383b5cc83231a71005d6
 compiler/coreSyn/CoreUtils.hs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index bb361a3..01b9047 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -839,6 +839,7 @@ getIdFromTrivialExpr_maybe :: CoreExpr -> Maybe Id
 getIdFromTrivialExpr_maybe e = go e
   where go (Var v) = Just v
         go (App f t) | not (isRuntimeArg t) = go f
+        go (ConApp dc args) | all isTypeArg args = Just (dataConWorkId dc)
         go (Tick t e) | not (tickishIsCode t) = go e
         go (Cast e _) = go e
         go (Lam b e) | not (isRuntimeVar b) = go e



More information about the ghc-commits mailing list