git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Another test, and a TODO
commit90503c57b886d966811247101d5f5eb47c8f689d authorPhil Freeman <paf31@cantab.net> dateMon 25 Nov 2013, 22:56 (13 years ago) parent50cf905
2 files changed+8
examples/passing/Rank2Types.ps+7 src/Language/PureScript/TypeChecker/Types.hs+1
examples/passing/Rank2Types.ps+7
@@ -8,3 +8,10 @@ foreign import runST :: forall a. (forall s. ST s a) -> a
88foreign import exampleST :: forall s. ST s Number
99
1010testST = runST exampleST
11+
12+foreign import push :: forall el. el -> [el] -> [el]
13+
14+replicateM :: forall m a. (forall x. x -> m x) -> (forall x y. m x -> (x -> m y) -> m y) -> Number -> m a -> m [a]
15+replicateM = \ret bind n m -> case n of
16+ 0 -> ret []
17+ n -> bind m (\x -> bind (replicateM ret bind (n - 1) m) (\xs -> ret (push x xs)))
src/Language/PureScript/TypeChecker/Types.hs+1
@@ -210,6 +210,7 @@ replaceAllVarsWithUnknowns :: Type -> Subst Check Type
210210replaceAllVarsWithUnknowns (ForAll ident ty) = replaceVarsWithUnknowns [ident] ty >>= replaceAllVarsWithUnknowns
211211replaceAllVarsWithUnknowns ty = return ty
212212
213+-- TODO: need to be careful inside a forall, since variables might be renamed
213214replaceVarsWithUnknowns :: [String] -> Type -> Subst Check Type
214215replaceVarsWithUnknowns idents = flip evalStateT M.empty . everywhereM (flip extM f $ mkM g)
215216 where