@@ -58,7 +58,7 @@ import System.IO
58import Control.Monad
58import Control.Monad
59import Control.Monad.Trans.Error (ErrorT(..))
59import Control.Monad.Trans.Error (ErrorT(..))
60import Control.Monad.Trans.State.Strict ( StateT, execStateT, get, put )
60import Control.Monad.Trans.State.Strict ( StateT, execStateT, get, put )
61−import Control.Monad.Trans ( liftIO, lift )
61+import Control.Monad.Trans ( lift )
62import Data.Maybe
62import Data.Maybe
63import Data.List
63import Data.List
64import Data.Char
64import Data.Char
@@ -111,7 +111,7 @@ ideslaveStart orig mods
111ideslave :: IState -> [FilePath] -> Idris ()
111ideslave :: IState -> [FilePath] -> Idris ()
112ideslave orig mods
112ideslave orig mods
113 = do idrisCatch
113 = do idrisCatch
114− (do l <- liftIO $ getLine
114+ (do l <- runIO $ getLine
115 let (sexp, id) = parseMessage l
115 let (sexp, id) = parseMessage l
116 i <- getIState
116 i <- getIState
117 putIState $ i { idris_outputmode = (IdeSlave id) }
117 putIState $ i { idris_outputmode = (IdeSlave id) }
@@ -134,7 +134,7 @@ ideslave orig mods
134 Just (REPLCompletions str) ->
134 Just (REPLCompletions str) ->
135 do (unused, compls) <- replCompletion (reverse str, "")
135 do (unused, compls) <- replCompletion (reverse str, "")
136 let good = SexpList [SymbolAtom "ok", toSExp (map replacement compls, reverse unused)]
136 let good = SexpList [SymbolAtom "ok", toSExp (map replacement compls, reverse unused)]
137− liftIO $ putStrLn $ convSExp "return" good id
137+ runIO $ putStrLn $ convSExp "return" good id
138 Just (LoadFile filename) ->
138 Just (LoadFile filename) ->
139 do clearErr
139 do clearErr
140 putIState (orig { idris_options = idris_options i,
140 putIState (orig { idris_options = idris_options i,
@@ -224,7 +224,7 @@ processInput cmd orig inputs
225 c <- colourise
225 c <- colourise
226 case parseCmd i "(input)" cmd of
226 case parseCmd i "(input)" cmd of
227− Failure err -> do liftIO $ print (fixColour c err)
227+ Failure err -> do runIO $ print (fixColour c err)
228 return (Just inputs)
228 return (Just inputs)
229 Success Reload ->
229 Success Reload ->
230 do putIState $ orig { idris_options = idris_options i
230 do putIState $ orig { idris_options = idris_options i
@@ -275,13 +275,13 @@ edit :: FilePath -> IState -> Idris ()
275edit "" orig = iputStrLn "Nothing to edit"
275edit "" orig = iputStrLn "Nothing to edit"
276edit f orig
276edit f orig
277 = do i <- getIState
277 = do i <- getIState
278− env <- liftIO $ getEnvironment
278+ env <- runIO $ getEnvironment
279 let editor = getEditor env
279 let editor = getEditor env
280 let line = case errLine i of
280 let line = case errLine i of
281 Just l -> " +" ++ show l ++ " "
281 Just l -> " +" ++ show l ++ " "
282 Nothing -> " "
282 Nothing -> " "
283 let cmd = editor ++ line ++ f
283 let cmd = editor ++ line ++ f
284− liftIO $ system cmd
284+ runIO $ system cmd
286 putIState $ orig { idris_options = idris_options i
286 putIState $ orig { idris_options = idris_options i
287 , idris_colourTheme = idris_colourTheme i
287 , idris_colourTheme = idris_colourTheme i
@@ -311,7 +311,7 @@ insertScript prf (x : xs) = x : insertScript prf xs
311process :: FilePath -> Command -> Idris ()
311process :: FilePath -> Command -> Idris ()
312process fn Help = iPrintResult displayHelp
312process fn Help = iPrintResult displayHelp
313process fn (ChangeDirectory f)
313process fn (ChangeDirectory f)
314− = do liftIO $ setCurrentDirectory f
314+ = do runIO $ setCurrentDirectory f
315 return ()
315 return ()
316process fn (Eval t)
316process fn (Eval t)
317 = do (tm, ty) <- elabVal toplevel False t
317 = do (tm, ty) <- elabVal toplevel False t
@@ -443,17 +443,17 @@ process fn (RmProof n')
444process fn' (AddProof prf)
444process fn' (AddProof prf)
445 = do fn <- do
445 = do fn <- do
446− ex <- liftIO $ doesFileExist fn'
446+ ex <- runIO $ doesFileExist fn'
447 let fnExt = fn' <.> "idr"
447 let fnExt = fn' <.> "idr"
448− exExt <- liftIO $ doesFileExist fnExt
448+ exExt <- runIO $ doesFileExist fnExt
450 then return fn'
450 then return fn'
451 else if exExt
451 else if exExt
452 then return fnExt
452 then return fnExt
453 else ifail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
453 else ifail $ "Neither \""++fn'++"\" nor \""++fnExt++"\" exist"
454 let fb = fn ++ "~"
454 let fb = fn ++ "~"
455− liftIO $ copyFile fn fb -- make a backup in case something goes wrong!
455+ runIO $ copyFile fn fb -- make a backup in case something goes wrong!
456− prog <- liftIO $ readFile fb
456+ prog <- runIO $ readFile fb
457 i <- getIState
457 i <- getIState
458 let proofs = proof_list i
458 let proofs = proof_list i
459 n' <- case prf of
459 n' <- case prf of
@@ -465,7 +465,7 @@ process fn' (AddProof prf)
465 case lookup n proofs of
465 case lookup n proofs of
466 Nothing -> iputStrLn "No proof to add"
466 Nothing -> iputStrLn "No proof to add"
467 Just p -> do let prog' = insertScript (showProof (lit fn) n p) ls
467 Just p -> do let prog' = insertScript (showProof (lit fn) n p) ls
468− liftIO $ writeFile fn (unlines prog')
468+ runIO $ writeFile fn (unlines prog')
469 removeProof n
469 removeProof n
470 iputStrLn $ "Added proof " ++ show n
470 iputStrLn $ "Added proof " ++ show n
471 where ls = (lines prog)
471 where ls = (lines prog)
@@ -513,11 +513,11 @@ process fn Execute = do (m, _) <- elabVal toplevel False
513 (PRef fc (UN "run__IO"))
513 (PRef fc (UN "run__IO"))
514 [pexp $ PRef fc (NS (UN "main") ["Main"])])
514 [pexp $ PRef fc (NS (UN "main") ["Main"])])
515-- (PRef (FC "main" 0) (NS (UN "main") ["main"]))
515-- (PRef (FC "main" 0) (NS (UN "main") ["main"]))
516− (tmpn, tmph) <- liftIO tempfile
516+ (tmpn, tmph) <- runIO tempfile
517− liftIO $ hClose tmph
517+ runIO $ hClose tmph
518 t <- codegen
518 t <- codegen
519 compile t tmpn m
519 compile t tmpn m
520− liftIO $ system tmpn
520+ runIO $ system tmpn
521 return ()
521 return ()
522 where fc = FC "main" 0
522 where fc = FC "main" 0
523process fn (Compile codegen f)
523process fn (Compile codegen f)
@@ -774,10 +774,10 @@ idrisMain opts =
775 xs -> last xs
775 xs -> last xs
776 trpl <- case opt getTriple opts of
776 trpl <- case opt getTriple opts of
777− [] -> liftIO $ getDefaultTargetTriple
777+ [] -> runIO $ getDefaultTargetTriple
778 xs -> return (last xs)
778 xs -> return (last xs)
779 tcpu <- case opt getCPU opts of
779 tcpu <- case opt getCPU opts of
780− [] -> liftIO $ getHostCPUName
780+ [] -> runIO $ getHostCPUName
781 xs -> return (last xs)
781 xs -> return (last xs)
782 let outty = case opt getOutputTy opts of
782 let outty = case opt getOutputTy opts of
783 [] -> Executable
783 [] -> Executable
@@ -788,7 +788,7 @@ idrisMain opts =
788 script <- case opt getExecScript opts of
788 script <- case opt getExecScript opts of
789 [] -> return Nothing
789 [] -> return Nothing
790 x:y:xs -> do iputStrLn "More than one interpreter expression found."
790 x:y:xs -> do iputStrLn "More than one interpreter expression found."
791− liftIO $ exitWith (ExitFailure 1)
791+ runIO $ exitWith (ExitFailure 1)
792 [expr] -> return (Just expr)
792 [expr] -> return (Just expr)
793 when (DefaultTotal `elem` opts) $ do i <- getIState
793 when (DefaultTotal `elem` opts) $ do i <- getIState
794 putIState (i { default_total = True })
794 putIState (i { default_total = True })
@@ -809,11 +809,11 @@ idrisMain opts =
809 -- if we have the --fovm flag, drop into the first order VM testing
809 -- if we have the --fovm flag, drop into the first order VM testing
810 case vm of
810 case vm of
811 [] -> return ()
811 [] -> return ()
812− xs -> liftIO $ mapM_ (fovm cgn outty) xs
812+ xs -> runIO $ mapM_ (fovm cgn outty) xs
813 -- if we have the --bytecode flag, drop into the bytecode assembler
813 -- if we have the --bytecode flag, drop into the bytecode assembler
814 case bcs of
814 case bcs of
815 [] -> return ()
815 [] -> return ()
816− xs -> return () -- liftIO $ mapM_ bcAsm xs
816+ xs -> return () -- runIO $ mapM_ bcAsm xs
817 case ibcsubdir of
817 case ibcsubdir of
818 [] -> setIBCSubDir ""
818 [] -> setIBCSubDir ""
819 (d:_) -> setIBCSubDir d
819 (d:_) -> setIBCSubDir d
@@ -829,7 +829,7 @@ idrisMain opts =
830 loadInputs inputs
830 loadInputs inputs
832− liftIO $ hSetBuffering stdout LineBuffering
832+ runIO $ hSetBuffering stdout LineBuffering
834 ok <- noErrors
834 ok <- noErrors
835 when ok $ case output of
835 when ok $ case output of
@@ -845,7 +845,7 @@ idrisMain opts =
845 when (runrepl && not idesl) $ runInputT (replSettings (Just historyFile)) $ repl ist inputs
845 when (runrepl && not idesl) $ runInputT (replSettings (Just historyFile)) $ repl ist inputs
846 when (idesl) $ ideslaveStart ist inputs
846 when (idesl) $ ideslaveStart ist inputs
847 ok <- noErrors
847 ok <- noErrors
848− when (not ok) $ liftIO (exitWith (ExitFailure 1))
848+ when (not ok) $ runIO (exitWith (ExitFailure 1))
850 makeOption (OLogging i) = setLogLevel i
850 makeOption (OLogging i) = setLogLevel i
851 makeOption TypeCase = setTypeCase True
851 makeOption TypeCase = setTypeCase True
@@ -855,7 +855,7 @@ idrisMain opts =
855 makeOption _ = return ()
855 makeOption _ = return ()
857 addPkgDir :: String -> Idris ()
857 addPkgDir :: String -> Idris ()
858− addPkgDir p = do ddir <- liftIO $ getDataDir
858+ addPkgDir p = do ddir <- runIO $ getDataDir
859 addImportDir (ddir </> p)
859 addImportDir (ddir </> p)
861execScript :: String -> Idris ()
861execScript :: String -> Idris ()
@@ -863,11 +863,11 @@ execScript expr = do i <- getIState
863 c <- colourise
863 c <- colourise
864 case parseExpr i expr of
864 case parseExpr i expr of
865 Failure err -> do iputStrLn $ show (fixColour c err)
865 Failure err -> do iputStrLn $ show (fixColour c err)
866− liftIO $ exitWith (ExitFailure 1)
866+ runIO $ exitWith (ExitFailure 1)
867 Success term -> do ctxt <- getContext
867 Success term -> do ctxt <- getContext
868 (tm, _) <- elabVal toplevel False term
868 (tm, _) <- elabVal toplevel False term
869 res <- execute tm
869 res <- execute tm
870− liftIO $ exitWith ExitSuccess
870+ runIO $ exitWith ExitSuccess
872-- | Check if the coloring matches the options and corrects if necessary
872-- | Check if the coloring matches the options and corrects if necessary
873fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
873fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
@@ -876,7 +876,7 @@ fixColour True doc = doc
877-- | Get the platform-specific, user-specific Idris dir
877-- | Get the platform-specific, user-specific Idris dir
878getIdrisUserDataDir :: Idris FilePath
878getIdrisUserDataDir :: Idris FilePath
879−getIdrisUserDataDir = liftIO $ getAppUserDataDirectory "idris"
879+getIdrisUserDataDir = runIO $ getAppUserDataDirectory "idris"
881-- | Locate the platform-specific location for the init script
881-- | Locate the platform-specific location for the init script
882getInitScript :: Idris FilePath
882getInitScript :: Idris FilePath
@@ -886,24 +886,24 @@ getInitScript = do idrisDir <- getIdrisUserDataDir
886-- | Run the initialisation script
886-- | Run the initialisation script
887initScript :: Idris ()
887initScript :: Idris ()
888initScript = do script <- getInitScript
888initScript = do script <- getInitScript
889− idrisCatch (do go <- liftIO $ doesFileExist script
889+ idrisCatch (do go <- runIO $ doesFileExist script
890 when go $ do
890 when go $ do
891− h <- liftIO $ openFile script ReadMode
891+ h <- runIO $ openFile script ReadMode
892 runInit h
892 runInit h
893− liftIO $ hClose h)
893+ runIO $ hClose h)
894 (\e -> iPrintError $ "Error reading init file: " ++ show e)
894 (\e -> iPrintError $ "Error reading init file: " ++ show e)
895 where runInit :: Handle -> Idris ()
895 where runInit :: Handle -> Idris ()
896 runInit h = do eof <- lift . lift $ hIsEOF h
896 runInit h = do eof <- lift . lift $ hIsEOF h
897 ist <- getIState
897 ist <- getIState
898 unless eof $ do
898 unless eof $ do
899− line <- liftIO $ hGetLine h
899+ line <- runIO $ hGetLine h
900 script <- getInitScript
900 script <- getInitScript
901 c <- colourise
901 c <- colourise
902 processLine ist line script c
902 processLine ist line script c
903 runInit h
903 runInit h
904 processLine i cmd input clr =
904 processLine i cmd input clr =
905 case parseCmd i input cmd of
905 case parseCmd i input cmd of
906− Failure err -> liftIO $ print (fixColour clr err)
906+ Failure err -> runIO $ print (fixColour clr err)
907 Success Reload -> iPrintError "Init scripts cannot reload the file"
907 Success Reload -> iPrintError "Init scripts cannot reload the file"
908 Success (Load f) -> iPrintError "Init scripts cannot load files"
908 Success (Load f) -> iPrintError "Init scripts cannot load files"
909 Success (ModImport f) -> iPrintError "Init scripts cannot import modules"
909 Success (ModImport f) -> iPrintError "Init scripts cannot import modules"