git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Traverse top-down in replaceTypeClassDictionaries, to avoid traversing the wrong part of the AST, for an approx 30% performance improvement when using type classes.
37fe621Phil Freeman
src/Language/PureScript/TypeChecker/Types.hs+2−1
@@ -47,6 +47,7 @@ import qualified Data.Data as D
47import Data.Generics
47import Data.Generics
48 (everythingWithContext, mkM, everywhereM, everything, mkT,
48 (everythingWithContext, mkM, everywhereM, everything, mkT,
49 something, everywhere, mkQ)
49 something, everywhere, mkQ)
50+import Data.Generics.Extras
50
51
51import Language.PureScript.Values
52import Language.PureScript.Values
52import Language.PureScript.Types
53import Language.PureScript.Types
@@ -249,7 +250,7 @@ overTypes f = everywhere (mkT f)
249-- Replace type class dictionary placeholders with inferred type class dictionaries
250-- Replace type class dictionary placeholders with inferred type class dictionaries
250--
251--
251replaceTypeClassDictionaries :: ModuleName -> Value -> Check Value
252replaceTypeClassDictionaries :: ModuleName -> Value -> Check Value
252−replaceTypeClassDictionaries mn = everywhereM (mkM go)
253+replaceTypeClassDictionaries mn = everywhereM' (mkM go)
253 where
254 where
254 go (TypeClassDictionary constraint dicts) = entails mn dicts constraint
255 go (TypeClassDictionary constraint dicts) = entails mn dicts constraint
255 go other = return other
256 go other = return other