on master help sign in
Add types and `deprime` function to SourceSyntax.Helpers
e22c7d4Evan Czaplicki
compiler/SourceSyntax/Helpers.hs+8−1
@@ -3,12 +3,19 @@ module SourceSyntax.Helpers where
3
3
4import qualified Data.Char as Char
4import qualified Data.Char as Char
5
5
6+brkt :: String -> String
6brkt s = "{ " ++ s ++ " }"
7brkt s = "{ " ++ s ++ " }"
7
8
9+isTuple :: String -> Bool
8isTuple name =
10isTuple name =
9 take 6 name == "_Tuple" && all Char.isDigit (drop 6 name)
11 take 6 name == "_Tuple" && all Char.isDigit (drop 6 name)
10
12
13+isOp :: String -> Bool
11isOp = all isSymbol
14isOp = all isSymbol
12
15
16+isSymbol :: Char -> Bool
13isSymbol c =
17isSymbol c =
14− Char.isSymbol c || elem c "+-/*=.$<>:&|^?%#@~!"
18+ Char.isSymbol c || elem c "+-/*=.$<>:&|^?%#@~!"
19+
20+deprime :: String -> String
21+deprime = map (\c -> if c == '\'' then '$' else c)