git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use evalSupplyT
e832819Phil Freeman
src/Language/PureScript.hs+2−2
@@ -78,7 +78,7 @@ compile' env opts ms = do
78 let elim = if null entryPoints then regrouped else eliminateDeadCode entryPoints regrouped
78 let elim = if null entryPoints then regrouped else eliminateDeadCode entryPoints regrouped
79 let codeGenModules = moduleNameFromString `map` optionsCodeGenModules opts
79 let codeGenModules = moduleNameFromString `map` optionsCodeGenModules opts
80 let modulesToCodeGen = if null codeGenModules then elim else filter (\(Module mn _ _) -> mn `elem` codeGenModules) elim
80 let modulesToCodeGen = if null codeGenModules then elim else filter (\(Module mn _ _) -> mn `elem` codeGenModules) elim
81− let (js, _) = runSupply nextVar $ concat <$> mapM (\m -> moduleToJs Globals opts m env') modulesToCodeGen
81+ let js = evalSupply nextVar $ concat <$> mapM (\m -> moduleToJs Globals opts m env') modulesToCodeGen
82 let exts = intercalate "\n" . map (`moduleToPs` env') $ modulesToCodeGen
82 let exts = intercalate "\n" . map (`moduleToPs` env') $ modulesToCodeGen
83 js' <- generateMain env' opts js
83 js' <- generateMain env' opts js
84 return (prettyPrintJS js', exts, env')
84 return (prettyPrintJS js', exts, env')
@@ -191,7 +191,7 @@ make outputDir opts ms = do
191
191
192 (desugared, nextVar) <- liftError $ stringifyErrorStack True $ runSupplyT 0 $ zip (map fst marked) <$> desugar (map snd marked)
192 (desugared, nextVar) <- liftError $ stringifyErrorStack True $ runSupplyT 0 $ zip (map fst marked) <$> desugar (map snd marked)
193
193
194− fst <$> runSupplyT nextVar (go initEnvironment desugared)
194+ evalSupplyT nextVar (go initEnvironment desugared)
195
195
196 where
196 where
197 go :: (Functor m, Applicative m, Monad m, MonadMake m) => Environment -> [(Bool, Module)] -> SupplyT m Environment
197 go :: (Functor m, Applicative m, Monad m, MonadMake m) => Environment -> [(Bool, Module)] -> SupplyT m Environment
src/Language/PureScript/Supply.hs+6
@@ -31,11 +31,17 @@ newtype SupplyT m a = SupplyT { unSupplyT :: StateT Integer m a } deriving (Func
31runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
31runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
32runSupplyT n = flip runStateT n . unSupplyT
32runSupplyT n = flip runStateT n . unSupplyT
33
33
34+evalSupplyT :: (Functor m) => Integer -> SupplyT m a -> m a
35+evalSupplyT n = fmap fst . runSupplyT n
36+
34type Supply = SupplyT Identity
37type Supply = SupplyT Identity
35
38
36runSupply :: Integer -> Supply a -> (a, Integer)
39runSupply :: Integer -> Supply a -> (a, Integer)
37runSupply n = runIdentity . runSupplyT n
40runSupply n = runIdentity . runSupplyT n
38
41
42+evalSupply :: Integer -> Supply a -> a
43+evalSupply n = runIdentity . evalSupplyT n
44+
39fresh :: (Monad m) => SupplyT m Integer
45fresh :: (Monad m) => SupplyT m Integer
40fresh = SupplyT $ do
46fresh = SupplyT $ do
41 n <- get
47 n <- get