[make some minor changes to typechecking code based on profiler output
John Meacham <john@repetae.net>**20090828142917
 Ignore-this: 9c29e48ce4ddce51da3ebff825c90280
] addfile ./bugs/issue-2ac0a447cd64f57d12304e1ce7f43c407c742642.yaml
hunk ./bugs/issue-2ac0a447cd64f57d12304e1ce7f43c407c742642.yaml 1
+--- !ditz.rubyforge.org,2008-03-06/issue 
+title: flattenType called too often in type checker
+desc: The type checker calls flattenType which traverses a whole type in places where the type is already flat, or we only need the head to not be a reference. This slows it down.
+type: :bugfix
+component: type_checker
+release: 
+reporter: John Meacham <john@repetae.net>
+status: :unstarted
+disposition: 
+creation_time: 2009-08-28 13:37:55.599760 Z
+references: []
+
+id: 2ac0a447cd64f57d12304e1ce7f43c407c742642
+log_events: 
+- - 2009-08-28 13:37:58.900152 Z
+  - John Meacham <john@repetae.net>
+  - created
+  - ""
hunk ./src/FrontEnd/Tc/Monad.hs 113
-    constraints      :: [Constraint],
+    constraints      :: Seq.Seq Constraint,
hunk ./src/FrontEnd/Tc/Monad.hs 314
-    Tc $ tell mempty { collectedPreds = [ p | p@IsIn {} <- ps ], constraints = [ Equality { constraintSrcLoc = sl, constraintType1 = a, constraintType2 = b } | IsEq a b <- ps ] }
+    Tc $ tell mempty { collectedPreds = [ p | p@IsIn {} <- ps ], constraints = Seq.fromList [ Equality { constraintSrcLoc = sl, constraintType1 = a, constraintType2 = b } | IsEq a b <- ps ] }
hunk ./src/FrontEnd/Tc/Monad.hs 317
-addConstraints ps = Tc $ tell mempty { constraints = ps }
+addConstraints ps = Tc $ tell mempty { constraints = Seq.fromList ps }
hunk ./src/FrontEnd/Tc/Monad.hs 323
-listenCPreds action = censor (\x -> x { constraints = mempty, collectedPreds = mempty }) $ listens (\x -> (collectedPreds x,constraints x)) action
+listenCPreds action = censor (\x -> x { constraints = mempty, collectedPreds = mempty }) $ listens (\x -> (collectedPreds x,T.toList $ constraints x)) action
hunk ./src/FrontEnd/Tc/Type.hs 70
-    constraintType1 :: Type,
-    constraintType2 ::Type
+    constraintType1  :: Type,
+    constraintType2  :: Type
hunk ./src/FrontEnd/Tc/Type.hs 146
-    openBoxes :: Bool,
-    failEmptyMetaVar :: Bool
+    openBoxes :: {-# UNPACK #-} !Bool,
+    failEmptyMetaVar :: {-# UNPACK #-} !Bool
hunk ./src/FrontEnd/Tc/Type.hs 150
+{-# SPECIALIZE flattenType :: MonadIO m => Type -> m Type #-}
hunk ./src/FrontEnd/Tc/Type.hs 269
-    tickleM f (IsEq t1 t2) = return IsEq `ap` f t1 `ap` f t2
+    tickleM f (IsEq t1 t2) = liftM2 IsEq (f t1) (f t2)
hunk ./src/FrontEnd/Tc/Type.hs 272
-    tickleM f (TAp l r) = return tAp `ap` f l `ap` f r
-    tickleM f (TArrow l r) = return TArrow `ap` f l `ap` f r
-    tickleM f (TAssoc c cas eas) = return (TAssoc c) `ap` mapM f cas `ap` mapM f eas
+    tickleM f (TAp l r) = liftM2 tAp (f l) (f r)
+    tickleM f (TArrow l r) = liftM2 TArrow (f l) (f r)
+    tickleM f (TAssoc c cas eas) = liftM2 (TAssoc c) (mapM f cas) (mapM f eas)
hunk ./src/FrontEnd/Tc/Type.hs 277
-        return (TForAll ta . (ps :=>)) `ap` f t
+        liftM (TForAll ta . (ps :=>)) (f t)
hunk ./src/FrontEnd/Tc/Type.hs 280
-        return (TExists ta . (ps :=>)) `ap` f t
+        liftM (TExists ta . (ps :=>)) (f t)