git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use double bang for array indexing
3deed0fPhil Freeman
examples/passing/Arrays.ps+1−2
@@ -1,4 +1,4 @@
1−test1 = \arr -> arr[0] + arr[1]
1+test1 = \arr -> arr !! 0 + arr !! 1
2
2
3test2 = \arr -> case arr of
3test2 = \arr -> case arr of
4 [x, y] -> x + y
4 [x, y] -> x + y
@@ -12,4 +12,3 @@ test3 = \tree, sum -> case tree of
12 One n -> n
12 One n -> n
13 Some [n1, n2 : rest] -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
13 Some [n1, n2 : rest] -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
14
14
15−test4 = \arr -> arr ! 0 + arr ! 1
libraries/prelude/prelude.ps+2−2
@@ -130,14 +130,14 @@ zipWith = \f -> \as -> \bs -> case { as: as, bs: bs } of
130any :: forall a. (a -> Boolean) -> [a] -> Boolean
130any :: forall a. (a -> Boolean) -> [a] -> Boolean
131any = \p -> \as -> do
131any = \p -> \as -> do
132 for i <- 0 until length as:
132 for i <- 0 until length as:
133− if p (as ! i):
133+ if p (as !! i):
134 return true
134 return true
135 return false
135 return false
136
136
137all :: forall a. (a -> Boolean) -> [a] -> Boolean
137all :: forall a. (a -> Boolean) -> [a] -> Boolean
138all = \p -> \as -> do
138all = \p -> \as -> do
139 for i <- 0 until length as:
139 for i <- 0 until length as:
140− if !(p (as ! i)):
140+ if !(p (as !! i)):
141 return false
141 return false
142 return true
142 return true
143
143
src/Language/PureScript/Parser/Values.hs+1−1
@@ -136,7 +136,7 @@ parseValue = do
136 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
136 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
137 ] ++ customOperatorTable user ++
137 ] ++ customOperatorTable user ++
138 [ [ Infix (C.lexeme (P.try (C.indented *> C.parseIdentInfix P.<?> "operator") >>= \ident -> return $ \t1 t2 -> App (App (Var ident) [t1]) [t2])) AssocLeft ]
138 [ [ Infix (C.lexeme (P.try (C.indented *> C.parseIdentInfix P.<?> "operator") >>= \ident -> return $ \t1 t2 -> App (App (Var ident) [t1]) [t2])) AssocLeft ]
139− , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (flip Indexer)) AssocRight ]
139+ , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "!!") >> return (flip Indexer)) AssocRight ]
140 , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "<=") >> return (Binary LessThanOrEqualTo)) AssocRight
140 , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "<=") >> return (Binary LessThanOrEqualTo)) AssocRight
141 , Infix (C.lexeme (P.try $ C.indented *> C.reservedOp ">=") >> return (Binary GreaterThanOrEqualTo)) AssocRight ]
141 , Infix (C.lexeme (P.try $ C.indented *> C.reservedOp ">=") >> return (Binary GreaterThanOrEqualTo)) AssocRight ]
142 , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "<") >> return (Binary LessThan)) AssocRight
142 , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "<") >> return (Binary LessThan)) AssocRight
src/Language/PureScript/Pretty/Values.hs+1−1
@@ -113,7 +113,7 @@ prettyPrintValue = fromMaybe (error "Incomplete pattern") . pattern matchValue
113 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
113 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
114 , [ Split lam $ \args val -> "\\" ++ intercalate ", " args ++ " -> " ++ prettyPrintValue val ]
114 , [ Split lam $ \args val -> "\\" ++ intercalate ", " args ++ " -> " ++ prettyPrintValue val ]
115 , [ Wrap ifThenElse $ \(th, el) cond -> cond ++ " ? " ++ prettyPrintValue th ++ " : " ++ prettyPrintValue el ]
115 , [ Wrap ifThenElse $ \(th, el) cond -> cond ++ " ? " ++ prettyPrintValue th ++ " : " ++ prettyPrintValue el ]
116− , [ AssocR indexer (\index val -> val ++ " ! " ++ index) ]
116+ , [ AssocR indexer (\index val -> val ++ " !! " ++ index) ]
117 , [ binary LessThan "<" ]
117 , [ binary LessThan "<" ]
118 , [ binary LessThanOrEqualTo "<=" ]
118 , [ binary LessThanOrEqualTo "<=" ]
119 , [ binary GreaterThan ">" ]
119 , [ binary GreaterThan ">" ]