git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Unicode operators
ea00235Phil Freeman
examples/passing/UnicodeOperators.pursnew file+20
@@ -0,0 +1,20 @@
1+module Main where
2+
3+compose :: forall a b c. (b -> c) -> (a -> b) -> a -> c
4+compose f g a = f (g a)
5+
6+infixr 9 compose as ∘
7+
8+test1 = (\x -> x) ∘ \y -> y
9+
10+elem :: forall a b. a -> (a -> Boolean) -> Boolean
11+elem x f = f x
12+
13+infixl 1 elem as ∈
14+
15+emptySet :: forall a. a -> Boolean
16+emptySet _ = true
17+
18+test2 = 1 ∈ emptySet
19+
20+main = Control.Monad.Eff.Console.log "Done"
src/Language/PureScript/Parser/Lexer.hs+5−5
@@ -67,13 +67,13 @@ module Language.PureScript.Parser.Lexer
67 , natural
67 , natural
68 , reservedPsNames
68 , reservedPsNames
69 , reservedTypeNames
69 , reservedTypeNames
70− , opChars
70+ , isSymbolChar
71 )
71 )
72 where
72 where
73
73
74import Prelude hiding (lex)
74import Prelude hiding (lex)
75
75
76−import Data.Char (isSpace)
76+import Data.Char (isSpace, isAscii, isSymbol)
77
77
78import Control.Monad (void, guard)
78import Control.Monad (void, guard)
79import Data.Functor.Identity
79import Data.Functor.Identity
@@ -233,7 +233,7 @@ parseToken = P.choice
233 uidentLetter = P.alphaNum <|> P.char '_'
233 uidentLetter = P.alphaNum <|> P.char '_'
234
234
235 symbolChar :: P.Parsec String u Char
235 symbolChar :: P.Parsec String u Char
236− symbolChar = P.oneOf opChars
236+ symbolChar = P.satisfy isSymbolChar
237
237
238 parseCharLiteral :: P.Parsec String u Char
238 parseCharLiteral :: P.Parsec String u Char
239 parseCharLiteral = PT.charLiteral tokenParser
239 parseCharLiteral = PT.charLiteral tokenParser
@@ -516,5 +516,5 @@ reservedTypeNames = [ "forall", "where" ]
516-- |
516-- |
517-- The characters allowed for use in operators
517-- The characters allowed for use in operators
518--
518--
519−opChars :: [Char]
519+isSymbolChar :: Char -> Bool
520−opChars = ":!#$%&*+./<=>?@\\^|-~"
520+isSymbolChar c = (c `elem` ":!#$%&*+./<=>?@\\^|-~") || (not (isAscii c) && isSymbol c)
src/Language/PureScript/Pretty/Common.hs+2−2
@@ -18,7 +18,7 @@ module Language.PureScript.Pretty.Common where
18import Control.Monad.State
18import Control.Monad.State
19import Data.List (intercalate)
19import Data.List (intercalate)
20
20
21−import Language.PureScript.Parser.Lexer (reservedPsNames, opChars)
21+import Language.PureScript.Parser.Lexer (reservedPsNames, isSymbolChar)
22
22
23import Text.PrettyPrint.Boxes
23import Text.PrettyPrint.Boxes
24
24
@@ -68,7 +68,7 @@ prettyPrintMany f xs = do
68--
68--
69prettyPrintObjectKey :: String -> String
69prettyPrintObjectKey :: String -> String
70prettyPrintObjectKey s | s `elem` reservedPsNames = show s
70prettyPrintObjectKey s | s `elem` reservedPsNames = show s
71− | any (`elem` opChars) s = show s
71+ | any isSymbolChar s = show s
72 | otherwise = s
72 | otherwise = s
73
73
74-- | Place a box before another, vertically when the first box takes up multiple lines.
74-- | Place a box before another, vertically when the first box takes up multiple lines.