11-- | This module contains the implementation of the @dhall repl@ subcommand
22
3+ {-# language CPP #-}
34{-# language FlexibleContexts #-}
45{-# language NamedFieldPuns #-}
56{-# language OverloadedStrings #-}
@@ -55,11 +56,16 @@ import qualified Dhall.TypeCheck as Dhall
5556import qualified Dhall.Version as Meta
5657import qualified System.Console.ANSI
5758import qualified System.Console.Haskeline.Completion as Haskeline
58- import qualified System.Console.Haskeline.MonadException as Haskeline
5959import qualified System.Console.Repline as Repline
6060import qualified System.IO
6161import qualified Text.Megaparsec as Megaparsec
6262
63+ #if MIN_VERSION_haskeline(0,8,0)
64+ import qualified Control.Monad.Catch
65+ #else
66+ import qualified System.Console.Haskeline.MonadException
67+ #endif
68+
6369type Repl = Repline. HaskelineT (State. StateT Env IO )
6470
6571-- | Implementation of the @dhall repl@ subcommand
@@ -293,9 +299,7 @@ nextSaveFile = do
293299
294300 pure $ saveFilePrefix <> " -" <> show nextIndex
295301
296- loadBinding
297- :: ( MonadFail m , MonadIO m , MonadState Env m , Haskeline. MonadException m )
298- => [String ] -> m ()
302+ loadBinding :: [String ] -> Repl ()
299303loadBinding [] = do
300304 mFile <- currentSaveFile
301305
@@ -402,7 +406,7 @@ cmdQuit _ = do
402406 liftIO (throwIO Interrupt )
403407
404408help
405- :: ( Haskeline. MonadException m , MonadFail m , MonadIO m , MonadState Env m )
409+ :: ( MonadFail m , MonadIO m , MonadState Env m )
406410 => HelpOptions m -> [String ] -> m ()
407411help hs _ = do
408412 liftIO (putStrLn " Type any expression to normalize it or use one of the following commands:" )
@@ -425,9 +429,7 @@ data HelpOption m = HelpOption
425429
426430type HelpOptions m = [HelpOption m ]
427431
428- helpOptions
429- :: ( Haskeline. MonadException m , MonadFail m , MonadIO m , MonadState Env m )
430- => HelpOptions m
432+ helpOptions :: HelpOptions Repl
431433helpOptions =
432434 [ HelpOption
433435 " help"
@@ -481,9 +483,7 @@ helpOptions =
481483 cmdQuit
482484 ]
483485
484- options
485- :: ( Haskeline. MonadException m , MonadFail m , MonadIO m , MonadState Env m )
486- => Repline. Options m
486+ options :: Repline. Options Repl
487487options = (\ h -> (helpOptionName h, helpOptionFunction h)) <$> helpOptions
488488
489489completer
@@ -579,9 +579,13 @@ greeter =
579579 in liftIO (putStrLn message)
580580
581581
582- dontCrash :: ( MonadIO m , Haskeline. MonadException m ) => m () -> m ()
582+ dontCrash :: Repl () -> Repl ()
583583dontCrash m =
584- Haskeline. catch
584+ #if MIN_VERSION_haskeline(0,8,0)
585+ Control.Monad.Catch. catch
586+ #else
587+ System.Console.Haskeline.MonadException. catch
588+ #endif
585589 m
586590 ( \ e@ SomeException {} -> liftIO ( putStrLn ( displayException e ) ) )
587591
0 commit comments