git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use evalSupplyT
commite832819ab510db54bffbed028449416bf7b1fda9 authorPhil Freeman <paf31@cantab.net> dateWed 21 May 2014, 12:22 (12 years ago) parent56fdde4
2 files changed+8−2
src/Language/PureScript.hs+2−2 src/Language/PureScript/Supply.hs+6
src/Language/PureScript.hs+2−2
@@ -78,7 +78,7 @@ compile' env opts ms = do
7878 let elim = if null entryPoints then regrouped else eliminateDeadCode entryPoints regrouped
7979 let codeGenModules = moduleNameFromString `map` optionsCodeGenModules opts
8080 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
8282 let exts = intercalate "\n" . map (`moduleToPs` env') $ modulesToCodeGen
8383 js' <- generateMain env' opts js
8484 return (prettyPrintJS js', exts, env')
@@ -191,7 +191,7 @@ make outputDir opts ms = do
191191
192192 (desugared, nextVar) <- liftError $ stringifyErrorStack True $ runSupplyT 0 $ zip (map fst marked) <$> desugar (map snd marked)
193193
194− fst <$> runSupplyT nextVar (go initEnvironment desugared)
194+ evalSupplyT nextVar (go initEnvironment desugared)
195195
196196 where
197197 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
3131runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
3232runSupplyT n = flip runStateT n . unSupplyT
3333
34+evalSupplyT :: (Functor m) => Integer -> SupplyT m a -> m a
35+evalSupplyT n = fmap fst . runSupplyT n
36+
3437type Supply = SupplyT Identity
3538
3639runSupply :: Integer -> Supply a -> (a, Integer)
3740runSupply n = runIdentity . runSupplyT n
3841
42+evalSupply :: Integer -> Supply a -> a
43+evalSupply n = runIdentity . evalSupplyT n
44+
3945fresh :: (Monad m) => SupplyT m Integer
4046fresh = SupplyT $ do
4147 n <- get