[commit: ghc] supercompiler: Give DataCons better tags (8a71f2f)

Max Bolingbroke <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : supercompiler

http://hackage.haskell.org/trac/ghc/changeset/8a71f2f6c712ab02d04c03520991ea682b7a2daa

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

commit 8a71f2f6c712ab02d04c03520991ea682b7a2daa
Author: Max Bolingbroke <[email protected]>
Date:   Tue Jan 3 13:53:13 2012 +0000

    Give DataCons better tags

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

 compiler/supercompile/Supercompile/Core/Tag.hs |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/compiler/supercompile/Supercompile/Core/Tag.hs b/compiler/supercompile/Supercompile/Core/Tag.hs
index 33b9eb8..82951b9 100644
--- a/compiler/supercompile/Supercompile/Core/Tag.hs
+++ b/compiler/supercompile/Supercompile/Core/Tag.hs
@@ -10,6 +10,7 @@ import Supercompile.Core.Syntax
 
 import qualified DataCon
 import Literal (hashLiteral)
+import Var (varUnique)
 
 
 tagTerm :: UniqSupply -> Term -> TaggedTerm
@@ -25,7 +26,8 @@ tagFVedTerm = mkTagger (\tg e -> Comp (Tagged tg e))
 -- are specialised on very long repititions of the same constructor.
 
 dataConTag :: DataCon -> Tag
-dataConTag dc = mkTag (negate (DataCon.dataConTag dc)) -- Works well because (hashLiteral l) is always positive
+--dataConTag dc = mkTag (negate (DataCon.dataConTag dc)) -- Works well because (hashLiteral l) is always positive
+dataConTag = mkTag . getKey . varUnique . DataCon.dataConWorkId -- This is much better because otherwise [], True and all dictionary all get the same tag!!
 
 literalTag :: Literal -> Tag
 literalTag = mkTag . hashLiteral
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.