Skip to content

Commit b0175e7

Browse files
authored
Support repline-0.3 (and haskeline-0.8 properly) (#1717)
1 parent 40767ac commit b0175e7

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

dhall/dhall.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ Library
474474
prettyprinter-ansi-terminal >= 1.1.1 && < 1.2 ,
475475
pretty-simple < 4 ,
476476
profunctors >= 3.1.2 && < 5.6 ,
477-
repline >= 0.2.1.0 && < 0.3 ,
477+
repline >= 0.2.1.0 && < 0.4 ,
478478
serialise >= 0.2.0.0 && < 0.3 ,
479479
scientific >= 0.3.0.0 && < 0.4 ,
480480
template-haskell >= 2.11.1.0 && < 2.16,

dhall/src/Dhall/Repl.hs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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
5556
import qualified Dhall.Version as Meta
5657
import qualified System.Console.ANSI
5758
import qualified System.Console.Haskeline.Completion as Haskeline
58-
import qualified System.Console.Haskeline.MonadException as Haskeline
5959
import qualified System.Console.Repline as Repline
6060
import qualified System.IO
6161
import 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+
6369
type 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 ()
299303
loadBinding [] = do
300304
mFile <- currentSaveFile
301305

@@ -402,7 +406,7 @@ cmdQuit _ = do
402406
liftIO (throwIO Interrupt)
403407

404408
help
405-
:: ( Haskeline.MonadException m, MonadFail m, MonadIO m, MonadState Env m )
409+
:: ( MonadFail m, MonadIO m, MonadState Env m )
406410
=> HelpOptions m -> [String] -> m ()
407411
help 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

426430
type 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
431433
helpOptions =
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
487487
options = (\h -> (helpOptionName h, helpOptionFunction h)) <$> helpOptions
488488

489489
completer
@@ -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 ()
583583
dontCrash 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

Comments
 (0)