@@ -29,6 +29,8 @@ import Data.List (intercalate, isPrefixOf, nub, sortBy)
29import Data.Maybe (mapMaybe)
29import Data.Maybe (mapMaybe)
30import Data.Traversable (traverse)
30import Data.Traversable (traverse)
32import System.Console.Haskeline
34import System.Console.Haskeline
33import System.Directory (doesFileExist, findExecutable, getHomeDirectory)
35import System.Directory (doesFileExist, findExecutable, getHomeDirectory)
34import System.Exit
36import System.Exit
@@ -36,13 +38,12 @@ import System.Environment.XDG.BaseDir
36import System.FilePath ((</>), isPathSeparator)
38import System.FilePath ((</>), isPathSeparator)
37import System.Process
39import System.Process
39−import qualified Parser
41+import Text.Parsec (choice)
41import qualified Data.Map as M
43import qualified Data.Map as M
42import qualified Language.PureScript as P
44import qualified Language.PureScript as P
43import qualified Paths_purescript as Paths
45import qualified Paths_purescript as Paths
44import qualified System.IO.UTF8 as U (readFile)
46import qualified System.IO.UTF8 as U (readFile)
45−import qualified Text.Parsec as Parsec (try)
48-- The PSCI state.
49-- The PSCI state.
@@ -117,7 +118,7 @@ getPreludeFilename = Paths.getDataFileName "prelude/prelude.purs"
117-- Loads a file for use with imports.
118-- Loads a file for use with imports.
119loadModule :: FilePath -> IO (Either String [P.Module])
120loadModule :: FilePath -> IO (Either String [P.Module])
120−loadModule = fmap (either (Left . show) Right . Parser.parseModules) . U.readFile
121+loadModule = fmap (either (Left . show) Right . parseModules) . U.readFile
123-- Expands tilde in path.
124-- Expands tilde in path.
@@ -243,9 +244,9 @@ handleTypeOf value (PSCI imports loadedModules lets) = do
243handleCommand :: Command -> StateT PSCI (InputT IO) ()
244handleCommand :: Command -> StateT PSCI (InputT IO) ()
244handleCommand Empty = return ()
245handleCommand Empty = return ()
245handleCommand (Expression ls) =
246handleCommand (Expression ls) =
246− case Parser.psciParser (Left <$> Parsec.try Parser.parseLet <|> Right <$> Parser.parseExpression) (unlines ls) of
247+ case psciParser (choice [Left <$> psciLet, Right <$> psciExpression]) (unlines ls) of
247− Left err -> inputTToState $ outputStrLn (show err)
248+ Left err -> inputTToState $ outputStrLn (show err)
248− Right (Left l) -> modify (updateLets l)
249+ Right (Left l) -> modify (updateLets l)
249 Right (Right decl) -> get >>= inputTToState . handleDeclaration decl
250 Right (Right decl) -> get >>= inputTToState . handleDeclaration decl
250handleCommand Help = inputTToState $ outputStrLn helpMessage
251handleCommand Help = inputTToState $ outputStrLn helpMessage
251handleCommand (Import moduleName) = modify (updateImports moduleName)
252handleCommand (Import moduleName) = modify (updateImports moduleName)
@@ -260,8 +261,8 @@ handleCommand Reload = do
260 (Right prelude) <- ioToState $ loadModule =<< getPreludeFilename
261 (Right prelude) <- ioToState $ loadModule =<< getPreludeFilename
261 put (PSCI defaultImports prelude [])
262 put (PSCI defaultImports prelude [])
262handleCommand (TypeOf expr) =
263handleCommand (TypeOf expr) =
263− case Parser.psciParser Parser.parseExpression expr of
264+ case parseExpression expr of
264− Left err -> inputTToState $ outputStrLn (show err)
265+ Left err -> inputTToState $ outputStrLn (show err)
265 Right expr' -> get >>= inputTToState . handleTypeOf expr'
266 Right expr' -> get >>= inputTToState . handleTypeOf expr'
266handleCommand _ = outputTStrLn "Unknown command"
267handleCommand _ = outputTStrLn "Unknown command"