aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Main.hs15
-rw-r--r--lang.cabal3
-rw-r--r--package.yaml1
-rw-r--r--src/Lib.hs7
-rw-r--r--stack.yaml2
-rw-r--r--stack.yaml.lock14
6 files changed, 39 insertions, 3 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 3e92547..6115252 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -2,6 +2,7 @@ module Main (main) where
import System.Environment
import Control.Monad.Except
import Control.Monad.Reader
+import System.Console.Haskeline
import Types
import Lib
@@ -16,6 +17,16 @@ parseArgs config args =
config { configShowHelp = True } rest
_ -> config
+repl :: InputT IO ()
+repl = do
+ minput <- getInputLine "> "
+ case minput of
+ Nothing -> return ()
+ Just "exit" -> return ()
+ Just input -> do
+ outputStrLn $ "Input was: " ++ input
+ repl
+
main :: IO ()
main = do
args <- getArgs
@@ -44,6 +55,6 @@ main = do
case result of
Left (LException ex) -> putStrLn $ "Error: " ++ ex
Right () -> return ()
- Nothing -> error "TODO REPL"
-
+ Nothing -> do
+ runInputT defaultSettings repl
return ()
diff --git a/lang.cabal b/lang.cabal
index 09fa5a1..2f2a91f 100644
--- a/lang.cabal
+++ b/lang.cabal
@@ -36,6 +36,7 @@ library
build-depends:
base >=4.7 && <5
, containers
+ , haskeline ==0.8.2
, mtl
default-language: Haskell2010
@@ -49,6 +50,7 @@ executable lang-exe
build-depends:
base >=4.7 && <5
, containers
+ , haskeline ==0.8.2
, lang
, mtl
default-language: Haskell2010
@@ -64,6 +66,7 @@ test-suite lang-test
build-depends:
base >=4.7 && <5
, containers
+ , haskeline ==0.8.2
, lang
, mtl
default-language: Haskell2010
diff --git a/package.yaml b/package.yaml
index 0ac218c..894f5f4 100644
--- a/package.yaml
+++ b/package.yaml
@@ -23,6 +23,7 @@ dependencies:
- base >= 4.7 && < 5
- containers
- mtl
+- haskeline == 0.8.2
ghc-options:
- -Wall
diff --git a/src/Lib.hs b/src/Lib.hs
index 7235c7e..28ab062 100644
--- a/src/Lib.hs
+++ b/src/Lib.hs
@@ -1,6 +1,6 @@
module Lib (
runScriptFile,
- LContext
+ runInlineScript,
) where
import qualified Data.Map as M
@@ -9,6 +9,7 @@ import Control.Monad.Except
import Control.Monad.Reader
import Data.List
import Debug.Trace
+import System.Console.Haskeline
import Types
import Utils
@@ -75,6 +76,10 @@ parse src = []
runScriptFile :: String -> LContext ()
runScriptFile fileName = do
src <- liftIO $ readFile fileName
+ runInlineScript src
+
+runInlineScript :: String -> LContext ()
+runInlineScript src = do
tokenized <- tokenize src
config <- ask
when (configVerboseMode config) $ liftIO $ putStrLn $ "tokenized:\t\t" ++ show tokenized
diff --git a/stack.yaml b/stack.yaml
index 1e45440..0a4ef42 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -4,3 +4,5 @@ system-ghc: true
resolver:
compiler: ghc-9.4.2
require-stack-version: ==2.7.5
+extra-deps:
+ - haskeline-0.8.2 \ No newline at end of file
diff --git a/stack.yaml.lock b/stack.yaml.lock
new file mode 100644
index 0000000..5200f97
--- /dev/null
+++ b/stack.yaml.lock
@@ -0,0 +1,14 @@
+# This file was autogenerated by Stack.
+# You should not edit this file by hand.
+# For more information, please see the documentation at:
+# https://docs.haskellstack.org/en/stable/lock_files
+
+packages:
+- completed:
+ hackage: haskeline-0.8.2@sha256:3a80aff4c751b475337ace00ac5757c5d47a47de94954fb87cce168a90e19c7a,6005
+ pantry-tree:
+ size: 2955
+ sha256: a51f2be1d61d077b8c972d762e9799983f08c95cae5123cf8ade8803e3250579
+ original:
+ hackage: haskeline-0.8.2
+snapshots: []