git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fibonacci example, fix inliner bug.
cd83a26Phil Freeman
examples/passing/Fib.pursnew file+15
@@ -0,0 +1,15 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff
5+import Control.Monad.ST
6+
7+main = runST (do
8+ n1 <- newSTRef 1
9+ n2 <- newSTRef 1
10+ whileE ((>) 1000 <$> readSTRef n1) $ do
11+ n1' <- readSTRef n1
12+ n2' <- readSTRef n2
13+ writeSTRef n2 $ n1' + n2'
14+ writeSTRef n1 n2'
15+ Debug.Trace.print n2')
src/Language/PureScript/Optimizer/Common.hs+1−1
@@ -47,7 +47,7 @@ isReassigned var1 = everything (||) (mkQ False check)
47 check _ = False
47 check _ = False
48
48
49isRebound :: (Data d) => JS -> d -> Bool
49isRebound :: (Data d) => JS -> d -> Bool
50−isRebound js d = any (`isReassigned` d) (everything (++) (mkQ [] variablesOf) js)
50+isRebound js d = any (\v -> isReassigned v d || isUpdated v d) (everything (++) (mkQ [] variablesOf) js)
51 where
51 where
52 variablesOf (JSVar var) = [var]
52 variablesOf (JSVar var) = [var]
53 variablesOf _ = []
53 variablesOf _ = []
src/Language/PureScript/Pretty/Values.hs+1−1
@@ -72,7 +72,7 @@ literals = mkPattern' match
72 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
72 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
73 , currentIndent
73 , currentIndent
74 ]
74 ]
75− match (TypeClassDictionary _ _) = error "Type class dictionary was not replaced"
75+ match (TypeClassDictionary _ _) = return "<<dict>>"
76 match (TypedValue _ val _) = prettyPrintValue' val
76 match (TypedValue _ val _) = prettyPrintValue' val
77 match (PositionedValue _ val) = prettyPrintValue' val
77 match (PositionedValue _ val) = prettyPrintValue' val
78 match _ = mzero
78 match _ = mzero