git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Allow $ as an operator
7e7cc99Phil Freeman
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
12 (|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
12 (|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
13 (|>) = \f -> \g -> \a -> g (f a)
13 (|>) = \f -> \g -> \a -> g (f a)
14
14
15+ infixr 5 |>
16+
15 (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
17 (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
16 (<|) = flip (|>)
18 (<|) = flip (|>)
17
19
20+ infixr 5 <|
21+
22+ ($) :: forall a b. (a -> b) -> a -> b
23+ ($) f x = f x
24+
25+ infixr 1000 $
26+
18module Maybe where
27module Maybe where
19
28
20 data Maybe a = Nothing | Just a
29 data Maybe a = Nothing | Just a
purescript.cabal+1−1
@@ -1,5 +1,5 @@
1name: purescript
1name: purescript
2−version: 0.2.3
2+version: 0.2.4
3cabal-version: >=1.8
3cabal-version: >=1.8
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
src/Language/PureScript/Parser/Common.hs+4−4
@@ -77,10 +77,10 @@ builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "
77 , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
77 , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
78
78
79reservedOpNames :: [String]
79reservedOpNames :: [String]
80−reservedOpNames = builtInOperators ++ [ "->", "=", "." ]
80+reservedOpNames = builtInOperators ++ [ "->", "=", ".", "\\" ]
81
81
82identStart :: P.Parsec String u Char
82identStart :: P.Parsec String u Char
83−identStart = P.lower <|> P.oneOf "_$"
83+identStart = P.lower <|> P.oneOf "_"
84
84
85properNameStart :: P.Parsec String u Char
85properNameStart :: P.Parsec String u Char
86properNameStart = P.upper
86properNameStart = P.upper
@@ -89,10 +89,10 @@ identLetter :: P.Parsec String u Char
89identLetter = P.alphaNum <|> P.oneOf "_'"
89identLetter = P.alphaNum <|> P.oneOf "_'"
90
90
91opStart :: P.Parsec String u Char
91opStart :: P.Parsec String u Char
92−opStart = P.oneOf ":.!#%&*+/<=>?@^|~"
92+opStart = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
93
93
94opLetter :: P.Parsec String u Char
94opLetter :: P.Parsec String u Char
95−opLetter = P.oneOf ":.#$%&*+./<=>?@^|"
95+opLetter = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
96
96
97langDef :: PT.GenLanguageDef String u Identity
97langDef :: PT.GenLanguageDef String u Identity
98langDef = PT.LanguageDef
98langDef = PT.LanguageDef
src/Language/PureScript/Parser/Values.hs+3−3
@@ -51,9 +51,9 @@ parseIdentifierAndValue = (,) <$> (C.indented *> C.identifier <* C.indented <* C
51
51
52parseAbs :: P.Parsec String ParseState Value
52parseAbs :: P.Parsec String ParseState Value
53parseAbs = do
53parseAbs = do
54− C.lexeme $ P.char '\\'
54+ C.reservedOp "\\"
55 args <- P.many (C.indented *> (P.try singleArg <|> manyArgs))
55 args <- P.many (C.indented *> (P.try singleArg <|> manyArgs))
56− C.lexeme $ C.indented *> P.string "->"
56+ C.indented *> C.reservedOp "->"
57 value <- parseValue
57 value <- parseValue
58 return $ toFunction args value
58 return $ toFunction args value
59 where
59 where
@@ -80,7 +80,7 @@ parseCase = Case <$> P.between (P.try (C.reserved "case")) (C.indented *> C.rese
80parseCaseAlternative :: P.Parsec String ParseState ([Binder], Maybe Guard, Value)
80parseCaseAlternative :: P.Parsec String ParseState ([Binder], Maybe Guard, Value)
81parseCaseAlternative = (,,) <$> (return <$> parseBinder)
81parseCaseAlternative = (,,) <$> (return <$> parseBinder)
82 <*> P.optionMaybe parseGuard
82 <*> P.optionMaybe parseGuard
83− <*> (C.lexeme (P.string "->") *> parseValue)
83+ <*> (C.indented *> C.reservedOp "->" *> parseValue)
84 P.<?> "case alternative"
84 P.<?> "case alternative"
85
85
86parseIfThenElse :: P.Parsec String ParseState Value
86parseIfThenElse :: P.Parsec String ParseState Value