Use haskeline-0.8 (#540)

The `MonadException` class was removed in favor of `MonadCatch`, so we
can remove its instances, enabling us to remove the library dependency
on haskeline.

To simplify dependency resolution with GHC < 8.10, this also disables
the executable in that configuration.
This commit is contained in:
Simon Jakobi 2020-05-30 03:32:20 +02:00 committed by GitHub
parent 707060260a
commit 9c6003ae8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 40 deletions

View File

@ -910,7 +910,6 @@ library
Nix.Options.Parser
build-depends:
base16-bytestring >= 0.1.1 && < 0.2
, haskeline >= 0.7.4.2 && < 0.8
, pretty-show >= 1.9.5 && < 1.11
, serialise >= 0.2.1 && < 0.3
-- if !flag(profiling)
@ -938,7 +937,7 @@ executable hnix
, exceptions
, filepath
, free
, haskeline
, haskeline >= 0.8.0.0 && < 0.9
, hnix
, mtl
, optparse-applicative
@ -954,6 +953,10 @@ executable hnix
, unordered-containers
if flag(optimize)
ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively -O2
if impl(ghc < 8.10)
-- GHC < 8.10 comes with haskeline < 0.8, which we don't support.
-- To simplify CI, we just disable the component.
buildable: False
if impl(ghcjs)
buildable: False
default-language: Haskell2010

View File

@ -52,19 +52,14 @@ import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.State.Strict
import System.Console.Haskeline.MonadException
import System.Console.Repline hiding ( options )
import System.Console.Repline hiding ( options, prefix )
import System.Environment
import System.Exit
main :: (MonadNix e t f m, MonadIO m, MonadException m) => m ()
main :: (MonadNix e t f m, MonadIO m, MonadMask m) => m ()
main = flip evalStateT initState
#if MIN_VERSION_repline(0, 2, 0)
$ evalRepl (return prefix) cmd options (Just ':') completer welcomeText
#else
$ evalRepl prefix cmd options completer welcomeText
#endif
where
prefix = "hnix> "
welcomeText =
@ -86,7 +81,7 @@ initState :: MonadIO m => IState t f m
initState = IState M.empty
type Repl e t f m = HaskelineT (StateT (IState t f m) m)
hoistErr :: MonadIO m => Result a -> Repl e t f m a
hoistErr :: (MonadIO m, MonadThrow m) => Result a -> Repl e t f m a
hoistErr (Success val) = return val
hoistErr (Failure err) = do
liftIO $ print err
@ -98,7 +93,7 @@ hoistErr (Failure err) = do
exec
:: forall e t f m
. (MonadNix e t f m, MonadIO m, MonadException m)
. (MonadNix e t f m, MonadIO m)
=> Bool
-> Text.Text
-> Repl e t f m (NValue t f m)
@ -129,7 +124,7 @@ exec update source = do
cmd
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m)
=> String
-> Repl e t f m ()
cmd source = do
@ -153,7 +148,7 @@ browse _ = do
-- :load command
load
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m)
=> [String]
-> Repl e t f m ()
load args = do
@ -162,7 +157,7 @@ load args = do
-- :type command
typeof
:: (MonadNix e t f m, MonadException m, MonadIO m)
:: (MonadNix e t f m, MonadIO m)
=> [String]
-> Repl e t f m ()
typeof args = do
@ -199,7 +194,7 @@ comp n = do
)
options
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m)
=> [(String, [String] -> Repl e t f m ())]
options =
[ ( "load"
@ -213,7 +208,7 @@ options =
help
:: forall e t f m
. (MonadNix e t f m, MonadIO m, MonadException m)
. (MonadNix e t f m, MonadIO m)
=> [String]
-> Repl e t f m ()
help _ = liftIO $ do

View File

@ -21,9 +21,6 @@ import Control.Monad.Reader
import Control.Monad.Ref
import Control.Monad.ST
import Data.Typeable
#ifdef MIN_VERSION_haskeline
import System.Console.Haskeline.MonadException hiding(catch)
#endif
import Nix.Var
import Nix.Thunk
@ -42,9 +39,7 @@ newtype FreshIdT i m a = FreshIdT { unFreshIdT :: ReaderT (Var m i) m a }
, MonadIO
, MonadCatch
, MonadThrow
#ifdef MIN_VERSION_haskeline
, MonadException
#endif
, MonadMask
)
instance MonadTrans (FreshIdT i) where

View File

@ -47,9 +47,6 @@ import Nix.Utils.Fix1
import Nix.Value
import Nix.Value.Monad
import Nix.Var
#ifdef MIN_VERSION_haskeline
import System.Console.Haskeline.MonadException hiding(catch)
#endif
-- All of the following type classes defer to the underlying 'm'.
@ -69,21 +66,6 @@ deriving instance MonadInstantiate (t (Fix1T t m) m) => MonadInstantiate (Fix1T
deriving instance MonadExec (t (Fix1T t m) m) => MonadExec (Fix1T t m)
deriving instance MonadIntrospect (t (Fix1T t m) m) => MonadIntrospect (Fix1T t m)
#ifdef MIN_VERSION_haskeline
-- For whatever reason, using the default StateT instance provided by
-- haskeline does not work.
instance MonadException m
=> MonadException(StateT(HashMap FilePath NExprLoc) m) where
controlIO f = StateT $ \s -> controlIO $ \(RunIO run) -> let
run' = RunIO(fmap(StateT . const) . run . flip runStateT s)
in fmap(flip runStateT s) $ f run'
instance MonadException m => MonadException(Fix1T StandardTF m) where
controlIO f = mkStandardT $ controlIO $ \(RunIO run) ->
let run' = RunIO(fmap mkStandardT . run . runStandardT)
in runStandardT <$> f run'
#endif
type MonadFix1T t m = (MonadTrans (Fix1T t), Monad (t (Fix1T t m) m))
instance (MonadFix1T t m, MonadRef m) => MonadRef (Fix1T t m) where
@ -219,6 +201,7 @@ newtype StandardTF r m a
, MonadIO
, MonadCatch
, MonadThrow
, MonadMask
, MonadReader (Context r (StdValue r))
, MonadState (HashMap FilePath NExprLoc)
)

View File

@ -48,6 +48,7 @@ deriving instance MonadFix (t (Fix1T t m) m) => MonadFix (Fix1T t m)
deriving instance MonadIO (t (Fix1T t m) m) => MonadIO (Fix1T t m)
deriving instance MonadCatch (t (Fix1T t m) m) => MonadCatch (Fix1T t m)
deriving instance MonadThrow (t (Fix1T t m) m) => MonadThrow (Fix1T t m)
deriving instance MonadMask (t (Fix1T t m) m) => MonadMask (Fix1T t m)
deriving instance MonadReader e (t (Fix1T t m) m) => MonadReader e (Fix1T t m)
deriving instance MonadState s (t (Fix1T t m) m) => MonadState s (Fix1T t m)