on master help sign in
Make Type.State.introduce allocate a bit less
commit696ee0a8623b76214e3ff0f0a21415c80266c37c authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 17 Jul 2017, 13:50 (9 years ago) parent09076eb
2 files changed+8−7
src/Type/Solve.hs+2−2 src/Type/State.hs+6−5
src/Type/Solve.hs+2−2
@@ -55,7 +55,7 @@ actuallySolve constraint =
5555
5656 CLet [Scheme [] fqs constraint' _] CTrue ->
5757 do oldEnv <- TS.getEnv
58− mapM_ TS.introduce fqs
58+ TS.introduce fqs
5959 actuallySolve constraint'
6060 TS.modifyEnv (\_ -> oldEnv)
6161
@@ -103,7 +103,7 @@ solveScheme scheme =
103103 -- fill in a new pool when working on this scheme's constraints
104104 freshPool <- TS.nextRankPool
105105 TS.switchToPool freshPool
106− mapM_ TS.introduce quantifiers
106+ TS.introduce quantifiers
107107 header' <- traverse flatten header
108108 actuallySolve constraint
109109
src/Type/State.hs+6−5
@@ -181,13 +181,14 @@ register variable =
181181
182182
183183{-# INLINE introduce #-}
184−introduce :: Variable -> Solver Variable
185−introduce variable =
184+introduce :: [Variable] -> Solver ()
185+introduce variables =
186186 {-# SCC elm_compiler_type_introduce #-}
187187 Solver $ \(SS env savedEnv (Pool maxRank inhabitants) mark errors) ->
188− do UF.modifyDescriptor variable $ \(Descriptor c _ m cp) -> Descriptor c maxRank m cp
189− let newPool = Pool maxRank (variable : inhabitants)
190− return ( variable, SS env savedEnv newPool mark errors )
188+ do let toMaxRank (Descriptor c _ m cp) = Descriptor c maxRank m cp
189+ mapM_ (\var -> UF.modifyDescriptor var toMaxRank) variables
190+ let newPool = Pool maxRank (variables ++ inhabitants)
191+ return ( (), SS env savedEnv newPool mark errors )
191192
192193
193194