@@ -13,7 +13,11 @@
14-----------------------------------------------------------------------------
14-----------------------------------------------------------------------------
16+{-# LANGUAGE DataKinds #-}
17+{-# LANGUAGE DoAndIfThenElse #-}
18+{-# LANGUAGE FlexibleContexts #-}
16−{-# LANGUAGE DataKinds, DoAndIfThenElse, FlexibleContexts, GeneralizedNewtypeDeriving #-}
19+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
20+{-# LANGUAGE RecordWildCards #-}
18module Main where
22module Main where
@@ -53,9 +57,8 @@ import qualified Paths_purescript as Paths
53import Commands as C
57import Commands as C
54import Parser
58import Parser
57data PSCiOptions = PSCiOptions
60data PSCiOptions = PSCiOptions
58− { psciSingleLineFlag :: Bool
61+ { psciMultiLineMode :: Bool
59 , psciInputFile :: [FilePath]
62 , psciInputFile :: [FilePath]
@@ -182,8 +185,6 @@ prologueMessage = intercalate "\n"
182 , " |_| "
185 , " |_| "
184 , ":? shows help"
187 , ":? shows help"
186− , "Expressions are terminated using Ctrl+D"
@@ -599,32 +600,33 @@ loadUserConfig = do
599-- The PSCI main loop.
600-- The PSCI main loop.
601loop :: PSCiOptions -> IO ()
602loop :: PSCiOptions -> IO ()
602−loop (PSCiOptions singleLineMode files) = do
603+loop PSCiOptions{..} = do
603 config <- loadUserConfig
604 config <- loadUserConfig
604− modulesOrFirstError <- loadAllModules files
605+ modulesOrFirstError <- loadAllModules psciInputFile
605 case modulesOrFirstError of
606 case modulesOrFirstError of
606 Left err -> print err >> exitFailure
607 Left err -> print err >> exitFailure
607 Right modules -> do
608 Right modules -> do
608 historyFilename <- getHistoryFilename
609 historyFilename <- getHistoryFilename
609 let settings = defaultSettings { historyFile = Just historyFilename }
610 let settings = defaultSettings { historyFile = Just historyFilename }
610− flip evalStateT (PSCiState files defaultImports modules []) . runInputT (setComplete completion settings) $ do
611+ flip evalStateT (PSCiState psciInputFile defaultImports modules []) . runInputT (setComplete completion settings) $ do
611 outputStrLn prologueMessage
612 outputStrLn prologueMessage
612 traverse_ (mapM_ (runPSCI . handleCommand)) config
613 traverse_ (mapM_ (runPSCI . handleCommand)) config
615 go :: InputT (StateT PSCiState IO) ()
616 go :: InputT (StateT PSCiState IO) ()
617− c <- getCommand singleLineMode
618+ c <- getCommand (not psciMultiLineMode)
618 case c of
619 case c of
619 Left err -> outputStrLn err >> go
620 Left err -> outputStrLn err >> go
620 Right Nothing -> go
621 Right Nothing -> go
621 Right (Just Quit) -> outputStrLn quitMessage
622 Right (Just Quit) -> outputStrLn quitMessage
622 Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
623 Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
624−singleLineFlag :: Parser Bool
625+multiLineMode :: Parser Bool
625−singleLineFlag = switch $
626+multiLineMode = switch $
626− long "single-line-mode"
627+ long "multi-line-mode"
627− <> Opts.help "Run in single-line mode"
629+ <> Opts.help "Run in multi-line mode (use ^D to terminate commands)"
629inputFile :: Parser FilePath
631inputFile :: Parser FilePath
630inputFile = strArgument $
632inputFile = strArgument $
@@ -632,7 +634,7 @@ inputFile = strArgument $
632 <> Opts.help "Optional .purs files to load on start"
634 <> Opts.help "Optional .purs files to load on start"
634psciOptions :: Parser PSCiOptions
636psciOptions :: Parser PSCiOptions
635−psciOptions = PSCiOptions <$> singleLineFlag
637+psciOptions = PSCiOptions <$> multiLineMode
636 <*> many inputFile
638 <*> many inputFile
638main :: IO ()
640main :: IO ()