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

dep: port to haskeline 0.8 #564

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion hnix.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ library
, cryptohash-sha1 >= 0.11.100 && < 0.12
, cryptohash-sha256 >= 0.11.101 && < 0.12
, cryptohash-sha512 >= 0.11.100 && < 0.12
, haskeline >= 0.7.4.2 && < 0.8
, haskeline >= 0.8 && < 0.9
, pretty-show >= 1.9.5 && < 1.11
, serialise >= 0.2.1 && < 0.3
-- if !flag(profiling)
Expand Down
19 changes: 9 additions & 10 deletions main/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.State.Strict

import System.Console.Haskeline.MonadException
import System.Console.Repline
import System.Console.Repline hiding ( options )
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
Expand Down Expand Up @@ -86,7 +85,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
Expand All @@ -98,7 +97,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, MonadMask m)
=> Bool
-> Text.Text
-> Repl e t f m (NValue t f m)
Expand Down Expand Up @@ -129,7 +128,7 @@ exec update source = do


cmd
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m, MonadMask m)
=> String
-> Repl e t f m ()
cmd source = do
Expand All @@ -153,7 +152,7 @@ browse _ = do

-- :load command
load
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m, MonadMask m)
=> [String]
-> Repl e t f m ()
load args = do
Expand All @@ -162,7 +161,7 @@ load args = do

-- :type command
typeof
:: (MonadNix e t f m, MonadException m, MonadIO m)
:: (MonadNix e t f m, MonadMask m, MonadIO m)
=> [String]
-> Repl e t f m ()
typeof args = do
Expand Down Expand Up @@ -199,7 +198,7 @@ comp n = do
)

options
:: (MonadNix e t f m, MonadIO m, MonadException m)
:: (MonadNix e t f m, MonadIO m, MonadMask m)
=> [(String, [String] -> Repl e t f m ())]
options =
[ ( "load"
Expand All @@ -213,7 +212,7 @@ options =

help
:: forall e t f m
. (MonadNix e t f m, MonadIO m, MonadException m)
. (MonadNix e t f m, MonadIO m, MonadMask m)
=> [String]
-> Repl e t f m ()
help _ = liftIO $ do
Expand Down
7 changes: 1 addition & 6 deletions src/Nix/Fresh.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
19 changes: 2 additions & 17 deletions src/Nix/Standard.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.

Expand All @@ -69,20 +66,7 @@ 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
deriving instance MonadMask m => MonadMask (Fix1T StandardTF m)

type MonadFix1T t m = (MonadTrans (Fix1T t), Monad (t (Fix1T t m) m))

Expand Down Expand Up @@ -219,6 +203,7 @@ newtype StandardTF r m a
, MonadIO
, MonadCatch
, MonadThrow
, MonadMask
, MonadReader (Context r (StdValue r))
, MonadState (HashMap FilePath NExprLoc)
)
Expand Down