Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/passing/UnicodeOperators.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Main where

compose :: forall a b c. (b -> c) -> (a -> b) -> a -> c
compose f g a = f (g a)

infixr 9 compose as ∘

test1 = (\x -> x) ∘ \y -> y

elem :: forall a b. a -> (a -> Boolean) -> Boolean
elem x f = f x

infixl 1 elem as ∈

emptySet :: forall a. a -> Boolean
emptySet _ = true

test2 = 1 ∈ emptySet

main = Control.Monad.Eff.Console.log "Done"
10 changes: 5 additions & 5 deletions src/Language/PureScript/Parser/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ module Language.PureScript.Parser.Lexer
, natural
, reservedPsNames
, reservedTypeNames
, opChars
, isSymbolChar
)
where

import Prelude hiding (lex)

import Data.Char (isSpace)
import Data.Char (isSpace, isAscii, isSymbol)

import Control.Monad (void, guard)
import Data.Functor.Identity
Expand Down Expand Up @@ -233,7 +233,7 @@ parseToken = P.choice
uidentLetter = P.alphaNum <|> P.char '_'

symbolChar :: P.Parsec String u Char
symbolChar = P.oneOf opChars
symbolChar = P.satisfy isSymbolChar

parseCharLiteral :: P.Parsec String u Char
parseCharLiteral = PT.charLiteral tokenParser
Expand Down Expand Up @@ -516,5 +516,5 @@ reservedTypeNames = [ "forall", "where" ]
-- |
-- The characters allowed for use in operators
--
opChars :: [Char]
opChars = ":!#$%&*+./<=>?@\\^|-~"
isSymbolChar :: Char -> Bool
isSymbolChar c = (c `elem` ":!#$%&*+./<=>?@\\^|-~") || (not (isAscii c) && isSymbol c)
4 changes: 2 additions & 2 deletions src/Language/PureScript/Pretty/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Language.PureScript.Pretty.Common where
import Control.Monad.State
import Data.List (intercalate)

import Language.PureScript.Parser.Lexer (reservedPsNames, opChars)
import Language.PureScript.Parser.Lexer (reservedPsNames, isSymbolChar)

import Text.PrettyPrint.Boxes

Expand Down Expand Up @@ -68,7 +68,7 @@ prettyPrintMany f xs = do
--
prettyPrintObjectKey :: String -> String
prettyPrintObjectKey s | s `elem` reservedPsNames = show s
| any (`elem` opChars) s = show s
| any isSymbolChar s = show s
| otherwise = s

-- | Place a box before another, vertically when the first box takes up multiple lines.
Expand Down