on 9b0c310 help sign in
elk/src/AST/Helpers.hs
29 lines 619 B history raw
1{-# OPTIONS_GHC -Wall #-}
2module AST.Helpers where
4import qualified Data.Char as Char
6splitDots :: String -> [String]
7splitDots variable =
8 go [] variable
9 where
10 go vars str =
11 case break (=='.') str of
12 (x,_:rest) | isOp x -> vars ++ [x ++ '.' : rest]
13 | otherwise -> go (vars ++ [x]) rest
14 (x,[]) -> vars ++ [x]
17isTuple :: String -> Bool
18isTuple name =
19 take 6 name == "_Tuple" && all Char.isDigit (drop 6 name)
22isOp :: String -> Bool
23isOp name =
24 all isSymbol name
27isSymbol :: Char -> Bool
28isSymbol c =
29 Char.isSymbol c || elem c "+-/*=.$<>:&|^?%#@~!"