@@ -46,6 +46,9 @@ instance (SExpable a) => SExpable (Maybe a) where
4646instance (SExpable a) => SExpable [a] where
4747 toSExp l = List (map toSExp l)
4848
49+instance (SExpable a, SExpable b) => SExpable (a, b) where
50+ toSExp (l, r) = List [toSExp l, toSExp r]
51+
4952escape :: String -> String
5053escape = concatMap escapeChar
5154 where
@@ -74,15 +77,15 @@ quotedChar = noneOf "\""
7477parseSExp :: String -> Either ParseError SExp
7578parseSExp input = parse pSExp "(unknown)" input
7679
77−data IdeSlaveCommand = Version
80+data IdeSlaveCommand = REPLCompletions String
7881 | Interpret String
7982 deriving Show
8083
8184sexpToCommand :: SExp -> Maybe IdeSlaveCommand
82−sexpToCommand (List (x:[])) = sexpToCommand x
83−sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
84−sexpToCommand (SymbolAtom "version") = Just Version
85−sexpToCommand _ = Nothing
85+sexpToCommand (List (x:[])) = sexpToCommand x
86+sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
87+sexpToCommand (List [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
88+sexpToCommand _ = Nothing
8689
8790receiveMessage :: IO (SExp)
8891receiveMessage
@@ -106,7 +109,7 @@ sendMessage id s =
106109 -- TODO: get real output here!!!
107110 case s of
108111 Left err -> putStrLn $ conv (List [SymbolAtom "abort", toSExp err])
109− Right succ -> putStrLn $ conv (List [SymbolAtom "ok", List [toSExp succ, StringAtom "no output"]])
112+ Right succ -> putStrLn $ conv (List [SymbolAtom "ok", toSExp succ])
110113 where conv sexp =
111114 let str = sExpToString (List [SymbolAtom "return", sexp, IntegerAtom id]) in (getHexLength str) ++ str
112115