on master help sign in
load-file support
commiteb6021bfa0d13c52d54a6cb002e88db4219edf4a authorHannes Mehnert <hannes@mehnert.org> dateWed 24 Apr 2013, 19:34 (14 years ago) parent0abbd53
2 files changed+7−1
src/Idris/IdeSlave.hs+4−1 src/Idris/REPL.hs+3
src/Idris/IdeSlave.hs+4−1
@@ -31,7 +31,8 @@ instance SExpable Bool where
3131 toSExp False = BoolAtom False
3232
3333instance SExpable String where
34− toSExp s = StringAtom s
34+ toSExp (':' : xs) = SymbolAtom xs
35+ toSExp s = StringAtom s
3536
3637instance SExpable Integer where
3738 toSExp n = IntegerAtom n
@@ -79,12 +80,14 @@ parseSExp input = parse pSExp "(unknown)" input
7980
8081data IdeSlaveCommand = REPLCompletions String
8182 | Interpret String
83+ | LoadFile String
8284 deriving Show
8385
8486sexpToCommand :: SExp -> Maybe IdeSlaveCommand
8587sexpToCommand (List (x:[])) = sexpToCommand x
8688sexpToCommand (List [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
8789sexpToCommand (List [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
90+sexpToCommand (List [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename)
8891sexpToCommand _ = Nothing
8992
9093receiveMessage :: IO (SExp)
src/Idris/REPL.hs+3
@@ -101,6 +101,9 @@ ideslave orig mods
101101 (\e -> do liftIO $ sendMessage id (Left (show e)))
102102 Just (REPLCompletions str) -> do (unused, compls) <- replCompletion (reverse str, "")
103103 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")
104107 Nothing -> do liftIO $ sendMessage id (Left "did not understand"))
105108 (\e -> do liftIO $ sendMessage 0 (Left (show e)))
106109 ideslave orig mods