git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Allow $ as an operator
commit7e7cc996d045fe989f0a0148ae23c927f7b5f31f authorPhil Freeman <paf31@cantab.net> dateTue 7 Jan 2014, 15:06 (13 years ago) parentec2e0e3
5 files changed+29−8
examples/passing/Dollar.purs+12 libraries/prelude/prelude.purs+9 purescript.cabal+1−1 src/Language/PureScript/Parser/Common.hs+4−4 src/Language/PureScript/Parser/Values.hs+3−3
examples/passing/Dollar.pursnew file+12
@@ -0,0 +1,12 @@
1+module Dollar where
2+
3+($) :: forall a b. (a -> b) -> a -> b
4+($) f x = f x
5+
6+infixr 1000 $
7+
8+id x = x
9+
10+test1 x = id $ id $ id $ id $ x
11+
12+test2 x = id id $ id x
libraries/prelude/prelude.purs+9
@@ -12,9 +12,18 @@ module Prelude where
1212 (|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
1313 (|>) = \f -> \g -> \a -> g (f a)
1414
15+ infixr 5 |>
16+
1517 (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
1618 (<|) = flip (|>)
1719
20+ infixr 5 <|
21+
22+ ($) :: forall a b. (a -> b) -> a -> b
23+ ($) f x = f x
24+
25+ infixr 1000 $
26+
1827module Maybe where
1928
2029 data Maybe a = Nothing | Just a
purescript.cabal+1−1
@@ -1,5 +1,5 @@
11name: purescript
2−version: 0.2.3
2+version: 0.2.4
33cabal-version: >=1.8
44build-type: Simple
55license: MIT
src/Language/PureScript/Parser/Common.hs+4−4
@@ -77,10 +77,10 @@ builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "
7777 , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
7878
7979reservedOpNames :: [String]
80−reservedOpNames = builtInOperators ++ [ "->", "=", "." ]
80+reservedOpNames = builtInOperators ++ [ "->", "=", ".", "\\" ]
8181
8282identStart :: P.Parsec String u Char
83−identStart = P.lower <|> P.oneOf "_$"
83+identStart = P.lower <|> P.oneOf "_"
8484
8585properNameStart :: P.Parsec String u Char
8686properNameStart = P.upper
@@ -89,10 +89,10 @@ identLetter :: P.Parsec String u Char
8989identLetter = P.alphaNum <|> P.oneOf "_'"
9090
9191opStart :: P.Parsec String u Char
92−opStart = P.oneOf ":.!#%&*+/<=>?@^|~"
92+opStart = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
9393
9494opLetter :: P.Parsec String u Char
95−opLetter = P.oneOf ":.#$%&*+./<=>?@^|"
95+opLetter = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
9696
9797langDef :: PT.GenLanguageDef String u Identity
9898langDef = PT.LanguageDef
src/Language/PureScript/Parser/Values.hs+3−3
@@ -51,9 +51,9 @@ parseIdentifierAndValue = (,) <$> (C.indented *> C.identifier <* C.indented <* C
5151
5252parseAbs :: P.Parsec String ParseState Value
5353parseAbs = do
54− C.lexeme $ P.char '\\'
54+ C.reservedOp "\\"
5555 args <- P.many (C.indented *> (P.try singleArg <|> manyArgs))
56− C.lexeme $ C.indented *> P.string "->"
56+ C.indented *> C.reservedOp "->"
5757 value <- parseValue
5858 return $ toFunction args value
5959 where
@@ -80,7 +80,7 @@ parseCase = Case <$> P.between (P.try (C.reserved "case")) (C.indented *> C.rese
8080parseCaseAlternative :: P.Parsec String ParseState ([Binder], Maybe Guard, Value)
8181parseCaseAlternative = (,,) <$> (return <$> parseBinder)
8282 <*> P.optionMaybe parseGuard
83− <*> (C.lexeme (P.string "->") *> parseValue)
83+ <*> (C.indented *> C.reservedOp "->" *> parseValue)
8484 P.<?> "case alternative"
8585
8686parseIfThenElse :: P.Parsec String ParseState Value