on master help sign in
load-file support
eb6021bHannes Mehnert
src/Idris/IdeSlave.hs+4−1
@@ -31,7 +31,8 @@ instance SExpable Bool where
31 toSExp False = BoolAtom False
31 toSExp False = BoolAtom False
32
32
33instance SExpable String where
33instance SExpable String where
34+ toSExp (':' : xs) = SymbolAtom xs
34− toSExp s = StringAtom s
35+ toSExp s = StringAtom s
35
36
36instance SExpable Integer where
37instance SExpable Integer where
37 toSExp n = IntegerAtom n
38 toSExp n = IntegerAtom n
@@ -79,12 +80,14 @@ parseSExp input = parse pSExp "(unknown)" input
79
80
80data IdeSlaveCommand = REPLCompletions String
81data IdeSlaveCommand = REPLCompletions String
81 | Interpret String
82 | Interpret String
83+ | LoadFile String
82 deriving Show
84 deriving Show
83
85
84sexpToCommand :: SExp -> Maybe IdeSlaveCommand
86sexpToCommand :: SExp -> Maybe IdeSlaveCommand
85sexpToCommand (List (x:[])) = sexpToCommand x
87sexpToCommand (List (x:[])) = sexpToCommand x
86sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
88sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
87sexpToCommand (List [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
89sexpToCommand (List [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
90+sexpToCommand (List [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename)
88sexpToCommand _ = Nothing
91sexpToCommand _ = Nothing
89
92
90receiveMessage :: IO (SExp)
93receiveMessage :: IO (SExp)
src/Idris/REPL.hs+3
@@ -101,6 +101,9 @@ ideslave orig mods
101 (\e -> do liftIO $ sendMessage id (Left (show e)))
101 (\e -> do liftIO $ sendMessage id (Left (show e)))
102 Just (REPLCompletions str) -> do (unused, compls) <- replCompletion (reverse str, "")
102 Just (REPLCompletions str) -> do (unused, compls) <- replCompletion (reverse str, "")
103 liftIO $ sendMessage id (Right (map replacement compls, reverse unused))
103 liftIO $ sendMessage id (Right (map replacement compls, reverse unused))
104+ Just (LoadFile filename) -> do clearErr
105+ mod <- loadModule filename
106+ liftIO $ sendMessage id (Right ":good")
104 Nothing -> do liftIO $ sendMessage id (Left "did not understand"))
107 Nothing -> do liftIO $ sendMessage id (Left "did not understand"))
105 (\e -> do liftIO $ sendMessage 0 (Left (show e)))
108 (\e -> do liftIO $ sendMessage 0 (Left (show e)))
106 ideslave orig mods
109 ideslave orig mods