summaryrefslogtreecommitdiff
path: root/utils/ext-core/Language
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2008-09-12 02:53:14 +0000
committerTim Chevalier <chevalier@alum.wellesley.edu>2008-09-12 02:53:14 +0000
commitce9526912145f8cf853877bda6fea86b6417fa01 (patch)
tree127afc5b905df4e201cda4c1a046daf8f31eb7cf /utils/ext-core/Language
parent809c7e56d9ee65312211127006475f8545afe4eb (diff)
downloadhaskell-ce9526912145f8cf853877bda6fea86b6417fa01.tar.gz
ext-core library: Fix performance bug
isUtupleTy was implemented inefficiently (and is called a lot by the typechecker). Replaced with uglier but faster code.
Diffstat (limited to 'utils/ext-core/Language')
-rw-r--r--utils/ext-core/Language/Core/Core.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/utils/ext-core/Language/Core/Core.hs b/utils/ext-core/Language/Core/Core.hs
index 74442bd67f..2b98ab7d08 100644
--- a/utils/ext-core/Language/Core/Core.hs
+++ b/utils/ext-core/Language/Core/Core.hs
@@ -5,6 +5,7 @@ import Language.Core.Encoding
import Data.Generics
import Data.List (elemIndex)
+import Data.Char
data Module
= Module AnMname [Tdef] [Vdefg]
@@ -102,7 +103,7 @@ data CoercionKind =
-- either type constructors or coercion names onto either
-- kinds or coercion kinds.
data KindOrCoercion = Kind Kind | Coercion CoercionKind
-
+
data Lit = Literal CoreLit Ty
deriving (Data, Typeable, Eq)
@@ -251,7 +252,15 @@ tUtuple ts = foldl Tapp (Tcon (tcUtuple (length ts))) ts
isUtupleTy :: Ty -> Bool
isUtupleTy (Tapp t _) = isUtupleTy t
-isUtupleTy (Tcon tc) = tc `elem` [tcUtuple n | n <- [1..maxUtuple]]
+isUtupleTy (Tcon tc) =
+ case tc of
+ (Just pm, 'Z':rest) | pm == primMname && last rest == 'H' ->
+ let mid = take ((length rest) - 1) rest in
+ all isDigit mid && (let num = read mid in
+ 1 <= num && num <= maxUtuple)
+ _ -> False
+-- The above is ugly, but less ugly than this:
+--tc `elem` [tcUtuple n | n <- [1..maxUtuple]]
isUtupleTy _ = False
dcUtuple :: Int -> Qual Dcon