Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :quit repl command #719

Merged
merged 4 commits into from
Nov 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dhall/src/Dhall/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Dhall.Binary (StandardVersion(..))
import Dhall.Import (standardVersion)
import Dhall.Pretty (CharacterSet(..))
import Lens.Family (set)
import System.Console.Haskeline (Interrupt(..))

import qualified Control.Monad.Trans.State.Strict as State
import qualified Data.Text as Text
Expand Down Expand Up @@ -234,6 +235,10 @@ saveBinding (file : "=" : tokens) = do
liftIO (System.IO.withFile file System.IO.WriteMode handler)
saveBinding _ = fail ":save should be of the form `:save x = y`"

cmdQuit :: ( MonadIO m, MonadState Env m ) => [String] -> m ()
cmdQuit _ = do
liftIO (putStrLn "Goodbye.")
liftIO (throwIO Interrupt)

options
:: ( Haskeline.MonadException m, MonadIO m, MonadState Env m )
Expand All @@ -242,6 +247,7 @@ options =
[ ( "type", dontCrash . typeOf )
, ( "let", dontCrash . addBinding )
, ( "save", dontCrash . saveBinding )
, ( "quit", cmdQuit )
]


Expand Down