git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use double bang for array indexing
commit3deed0f4f5fa720e809c494be16c603158736132 authorPhil Freeman <paf31@cantab.net> dateThu 7 Nov 2013, 09:18 (13 years ago) parentc7b1be2
4 files changed+5−6
examples/passing/Arrays.ps+1−2 libraries/prelude/prelude.ps+2−2 src/Language/PureScript/Parser/Values.hs+1−1 src/Language/PureScript/Pretty/Values.hs+1−1
examples/passing/Arrays.ps+1−2
@@ -1,4 +1,4 @@
1−test1 = \arr -> arr[0] + arr[1]
1+test1 = \arr -> arr !! 0 + arr !! 1
22
33test2 = \arr -> case arr of
44 [x, y] -> x + y
@@ -12,4 +12,3 @@ test3 = \tree, sum -> case tree of
1212 One n -> n
1313 Some [n1, n2 : rest] -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
1414
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
130130any :: forall a. (a -> Boolean) -> [a] -> Boolean
131131any = \p -> \as -> do
132132 for i <- 0 until length as:
133− if p (as ! i):
133+ if p (as !! i):
134134 return true
135135 return false
136136
137137all :: forall a. (a -> Boolean) -> [a] -> Boolean
138138all = \p -> \as -> do
139139 for i <- 0 until length as:
140− if !(p (as ! i)):
140+ if !(p (as !! i)):
141141 return false
142142 return true
143143
src/Language/PureScript/Parser/Values.hs+1−1
@@ -136,7 +136,7 @@ parseValue = do
136136 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
137137 ] ++ customOperatorTable user ++
138138 [ [ 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 ]
140140 , [ Infix (C.lexeme (P.try $ C.indented *> C.reservedOp "<=") >> return (Binary LessThanOrEqualTo)) AssocRight
141141 , Infix (C.lexeme (P.try $ C.indented *> C.reservedOp ">=") >> return (Binary GreaterThanOrEqualTo)) AssocRight ]
142142 , [ 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
113113 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
114114 , [ Split lam $ \args val -> "\\" ++ intercalate ", " args ++ " -> " ++ prettyPrintValue val ]
115115 , [ Wrap ifThenElse $ \(th, el) cond -> cond ++ " ? " ++ prettyPrintValue th ++ " : " ++ prettyPrintValue el ]
116− , [ AssocR indexer (\index val -> val ++ " ! " ++ index) ]
116+ , [ AssocR indexer (\index val -> val ++ " !! " ++ index) ]
117117 , [ binary LessThan "<" ]
118118 , [ binary LessThanOrEqualTo "<=" ]
119119 , [ binary GreaterThan ">" ]