Support repline 0.4
Closes #651. `haskeline` override needs `dontCheck` as it tries to run an executable. Tested build and repl itself.
This commit is contained in:
parent
704323ecd6
commit
710bc84309
|
@ -958,7 +958,7 @@ executable hnix
|
||||||
, pretty-show
|
, pretty-show
|
||||||
, prettyprinter
|
, prettyprinter
|
||||||
, ref-tf
|
, ref-tf
|
||||||
, repline
|
, repline >= 0.4.0.0 && < 0.5
|
||||||
, serialise
|
, serialise
|
||||||
, template-haskell
|
, template-haskell
|
||||||
, text
|
, text
|
||||||
|
|
28
main/Repl.hs
28
main/Repl.hs
|
@ -58,7 +58,15 @@ import System.Exit
|
||||||
|
|
||||||
main :: (MonadNix e t f m, MonadIO m, MonadMask m) => m ()
|
main :: (MonadNix e t f m, MonadIO m, MonadMask m) => m ()
|
||||||
main = flip evalStateT initState
|
main = flip evalStateT initState
|
||||||
$ evalRepl (return prefix) cmd options (Just ':') completer welcomeText
|
$ evalRepl
|
||||||
|
(const $ return prefix)
|
||||||
|
cmd
|
||||||
|
options
|
||||||
|
(Just ':')
|
||||||
|
Nothing
|
||||||
|
completer
|
||||||
|
welcomeText
|
||||||
|
(return Exit)
|
||||||
where
|
where
|
||||||
prefix = "hnix> "
|
prefix = "hnix> "
|
||||||
welcomeText =
|
welcomeText =
|
||||||
|
@ -139,7 +147,7 @@ cmd source = do
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- :browse command
|
-- :browse command
|
||||||
browse :: MonadNix e t f m => [String] -> Repl e t f m ()
|
browse :: MonadNix e t f m => String -> Repl e t f m ()
|
||||||
browse _ = do
|
browse _ = do
|
||||||
st <- get
|
st <- get
|
||||||
undefined
|
undefined
|
||||||
|
@ -148,16 +156,16 @@ browse _ = do
|
||||||
-- :load command
|
-- :load command
|
||||||
load
|
load
|
||||||
:: (MonadNix e t f m, MonadIO m)
|
:: (MonadNix e t f m, MonadIO m)
|
||||||
=> [String]
|
=> String
|
||||||
-> Repl e t f m ()
|
-> Repl e t f m ()
|
||||||
load args = do
|
load args = do
|
||||||
contents <- liftIO $ Text.readFile (unwords args)
|
contents <- liftIO $ Text.readFile args
|
||||||
void $ exec True contents
|
void $ exec True contents
|
||||||
|
|
||||||
-- :type command
|
-- :type command
|
||||||
typeof
|
typeof
|
||||||
:: (MonadNix e t f m, MonadIO m)
|
:: (MonadNix e t f m, MonadIO m)
|
||||||
=> [String]
|
=> String
|
||||||
-> Repl e t f m ()
|
-> Repl e t f m ()
|
||||||
typeof args = do
|
typeof args = do
|
||||||
st <- get
|
st <- get
|
||||||
|
@ -166,7 +174,7 @@ typeof args = do
|
||||||
Nothing -> exec False line
|
Nothing -> exec False line
|
||||||
str <- lift $ lift $ showValueType val
|
str <- lift $ lift $ showValueType val
|
||||||
liftIO $ putStrLn str
|
liftIO $ putStrLn str
|
||||||
where line = Text.pack (unwords args)
|
where line = Text.pack args
|
||||||
|
|
||||||
-- :quit command
|
-- :quit command
|
||||||
quit :: (MonadNix e t f m, MonadIO m) => a -> Repl e t f m ()
|
quit :: (MonadNix e t f m, MonadIO m) => a -> Repl e t f m ()
|
||||||
|
@ -194,11 +202,9 @@ comp n = do
|
||||||
|
|
||||||
options
|
options
|
||||||
:: (MonadNix e t f m, MonadIO m)
|
:: (MonadNix e t f m, MonadIO m)
|
||||||
=> [(String, [String] -> Repl e t f m ())]
|
=> System.Console.Repline.Options (Repl e t f m)
|
||||||
options =
|
options =
|
||||||
[ ( "load"
|
[ ( "load" , load)
|
||||||
, load
|
|
||||||
)
|
|
||||||
--, ("browse" , browse)
|
--, ("browse" , browse)
|
||||||
, ("quit", quit)
|
, ("quit", quit)
|
||||||
, ("type", typeof)
|
, ("type", typeof)
|
||||||
|
@ -208,7 +214,7 @@ options =
|
||||||
help
|
help
|
||||||
:: forall e t f m
|
:: forall e t f m
|
||||||
. (MonadNix e t f m, MonadIO m)
|
. (MonadNix e t f m, MonadIO m)
|
||||||
=> [String]
|
=> String
|
||||||
-> Repl e t f m ()
|
-> Repl e t f m ()
|
||||||
help _ = liftIO $ do
|
help _ = liftIO $ do
|
||||||
putStrLn "Available commands:\n"
|
putStrLn "Available commands:\n"
|
||||||
|
|
Loading…
Reference in a new issue