@@ -8,7 +8,7 @@ import Data.List
88-- import qualified Data.Text as T
99import Text.Parsec
1010
11−data SExp = List [SExp]
11+data SExp = SexpList [SExp]
1212 | StringAtom String
1313 | BoolAtom Bool
1414 | IntegerAtom Integer
@@ -21,7 +21,7 @@ sExpToString (BoolAtom True) = ":True"
2121sExpToString (BoolAtom False) = ":False"
2222sExpToString (IntegerAtom i) = printf "%d" i
2323sExpToString (SymbolAtom s) = ":" ++ s
24−sExpToString (List l) = "(" ++ intercalate " " (map sExpToString l) ++ ")"
24+sExpToString (SexpList l) = "(" ++ intercalate " " (map sExpToString l) ++ ")"
2525
2626class SExpable a where
2727 toSExp :: a -> SExp
@@ -29,9 +29,6 @@ class SExpable a where
2929instance SExpable SExp where
3030 toSExp a = a
3131
32−instance SExpable () where
33− toSExp a = List [ StringAtom "Unit" ]
34−
3532instance SExpable Bool where
3633 toSExp True = BoolAtom True
3734 toSExp False = BoolAtom False
@@ -46,17 +43,17 @@ instance SExpable Int where
4643 toSExp n = IntegerAtom (toInteger n)
4744
4845instance (SExpable a) => SExpable (Maybe a) where
49− toSExp Nothing = List [SymbolAtom "Nothing"]
50− toSExp (Just a) = List [SymbolAtom "Just", toSExp a]
46+ toSExp Nothing = SexpList [SymbolAtom "Nothing"]
47+ toSExp (Just a) = SexpList [SymbolAtom "Just", toSExp a]
5148
5249instance (SExpable a) => SExpable [a] where
53− toSExp l = List (map toSExp l)
50+ toSExp l = SexpList (map toSExp l)
5451
5552instance (SExpable a, SExpable b) => SExpable (a, b) where
56− toSExp (l, r) = List [toSExp l, toSExp r]
53+ toSExp (l, r) = SexpList [toSExp l, toSExp r]
5754
5855instance (SExpable a, SExpable b, SExpable c) => SExpable (a, b, c) where
59− toSExp (l, m, n) = List [toSExp l, toSExp m, toSExp n]
56+ toSExp (l, m, n) = SexpList [toSExp l, toSExp m, toSExp n]
6057
6158escape :: String -> String
6259escape = concatMap escapeChar
@@ -66,7 +63,7 @@ escape = concatMap escapeChar
6663 escapeChar c = [c]
6764
6865pSExp = do xs <- between (char '(') (char ')') (pSExp `sepBy` (char ' '))
69− return (List xs)
66+ return (SexpList xs)
7067 <|> atom
7168
7269atom = do char ':'; x <- atomC; return x
@@ -93,15 +90,15 @@ data IdeSlaveCommand = REPLCompletions String
9390 deriving Show
9491
9592sexpToCommand :: SExp -> Maybe IdeSlaveCommand
96−sexpToCommand (List (x:[])) = sexpToCommand x
97−sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
98−sexpToCommand (List [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
99−sexpToCommand (List [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename)
93+sexpToCommand (SexpList (x:[])) = sexpToCommand x
94+sexpToCommand (SexpList [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
95+sexpToCommand (SexpList [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
96+sexpToCommand (SexpList [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename)
10097sexpToCommand _ = Nothing
10198
10299parseMessage :: String -> (SExp, Integer)
103100parseMessage x = case receiveString x of
104− (List [cmd, (IntegerAtom id)]) ->
101+ (SexpList [cmd, (IntegerAtom id)]) ->
105102 (cmd, id)
106103
107104receiveString :: String -> SExp
@@ -118,7 +115,7 @@ receiveString x =
118115
119116convSExp :: SExpable a => String -> a -> Integer -> String
120117convSExp pre s id =
121− let sex = List [SymbolAtom pre, toSExp s, IntegerAtom id] in
118+ let sex = SexpList [SymbolAtom pre, toSExp s, IntegerAtom id] in
122119 let str = sExpToString sex in
123120 (getHexLength str) ++ str
124121