Skip to content

Commit 87d0578

Browse files
snoybergborsboom
authored andcommitted
Support unliftio-0.2.0.0 #3625
1 parent f7d38b4 commit 87d0578

File tree

6 files changed

+29
-6
lines changed

6 files changed

+29
-6
lines changed

src/Stack/Build/Execute.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ data ExcludeTHLoading = ExcludeTHLoading | KeepTHLoading
17661766
data ConvertPathsToAbsolute = ConvertPathsToAbsolute | KeepPathsAsIs
17671767

17681768
-- | Strip Template Haskell "Loading package" lines and making paths absolute.
1769-
mungeBuildOutput :: forall m. (MonadUnliftIO m, MonadThrow m)
1769+
mungeBuildOutput :: forall m. MonadIO m
17701770
=> ExcludeTHLoading -- ^ exclude TH loading?
17711771
-> ConvertPathsToAbsolute -- ^ convert paths to absolute?
17721772
-> Path Abs Dir -- ^ package's root directory

src/Stack/Prelude.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
{-# LANGUAGE OverloadedStrings #-}
44
module Stack.Prelude
55
( mapLeft
6+
, ResourceT
67
, runConduitRes
8+
, runResourceT
9+
, liftResourceT
10+
, NoLogging (..)
711
, withSystemTempDir
812
, fromFirst
913
, mapMaybeA
@@ -107,6 +111,9 @@ import UnliftIO as X
107111
import qualified Data.Text as T
108112
import qualified Path.IO
109113

114+
import qualified Control.Monad.Trans.Resource as Res (runResourceT, transResourceT)
115+
import Control.Monad.Trans.Resource.Internal (ResourceT (ResourceT))
116+
110117
mapLeft :: (a1 -> a2) -> Either a1 b -> Either a2 b
111118
mapLeft f (Left a1) = Left (f a1)
112119
mapLeft _ (Right b) = Right b
@@ -137,6 +144,22 @@ stripCR t = fromMaybe t (T.stripSuffix "\r" t)
137144
runConduitRes :: MonadUnliftIO m => ConduitM () Void (ResourceT m) r -> m r
138145
runConduitRes = runResourceT . runConduit
139146

147+
runResourceT :: MonadUnliftIO m => ResourceT m a -> m a
148+
runResourceT r = withRunInIO $ \run -> Res.runResourceT (Res.transResourceT run r)
149+
150+
liftResourceT :: MonadIO m => ResourceT IO a -> ResourceT m a
151+
liftResourceT (ResourceT f) = ResourceT $ liftIO . f
152+
153+
-- | Avoid orphan messes
154+
newtype NoLogging a = NoLogging { runNoLogging :: IO a }
155+
deriving (Functor, Applicative, Monad, MonadIO)
156+
instance MonadUnliftIO NoLogging where
157+
askUnliftIO = NoLogging $
158+
withUnliftIO $ \u ->
159+
return (UnliftIO (unliftIO u . runNoLogging))
160+
instance MonadLogger NoLogging where
161+
monadLoggerLog _ _ _ _ = return ()
162+
140163
-- | Path version
141164
withSystemTempDir :: MonadUnliftIO m => String -> (Path Abs Dir -> m a) -> m a
142165
withSystemTempDir str inner = withRunInIO $ \run -> Path.IO.withSystemTempDir str $ run . inner

src/main/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Main (main) where
1919
import qualified Build_stack
2020
#endif
2121
import Stack.Prelude
22-
import Control.Monad.Logger (runNoLoggingT)
2322
import Control.Monad.Reader (local)
2423
import Control.Monad.Trans.Except (ExceptT)
2524
import Control.Monad.Writer.Lazy (Writer)
@@ -508,7 +507,7 @@ secondaryCommandHandler args f =
508507
-- TODO show the command in verbose mode
509508
-- hPutStrLn stderr $ unwords $
510509
-- ["Running", "[" ++ ex, unwords (tail args) ++ "]"]
511-
_ <- runNoLoggingT (exec menv ex (tail args))
510+
_ <- runNoLogging (exec menv ex (tail args))
512511
return f
513512
Nothing -> return $ fmap (vcatErrorHelp (noSuchCmd cmd)) f
514513
where

src/test/Stack/PackageDumpSpec.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{-# LANGUAGE TupleSections #-}
55
module Stack.PackageDumpSpec where
66

7-
import Control.Monad.Logger
87
import Data.Conduit
98
import qualified Data.Conduit.Binary as CB
109
import qualified Data.Conduit.List as CL
@@ -208,7 +207,7 @@ spec = do
208207
}
209208

210209

211-
it "ghcPkgDump + addProfiling + addHaddock" $ (id :: IO () -> IO ()) $ runNoLoggingT $ do
210+
it "ghcPkgDump + addProfiling + addHaddock" $ (id :: IO () -> IO ()) $ runNoLogging $ do
212211
menv' <- getEnvOverride buildPlatform
213212
menv <- mkEnvOverride buildPlatform $ Map.delete "GHC_PACKAGE_PATH" $ unEnvOverride menv'
214213
icache <- newInstalledCache
@@ -223,7 +222,7 @@ spec = do
223222
menv' <- getEnvOverride buildPlatform
224223
menv <- mkEnvOverride buildPlatform $ Map.delete "GHC_PACKAGE_PATH" $ unEnvOverride menv'
225224
icache <- newInstalledCache
226-
m <- runNoLoggingT $ ghcPkgDump menv Ghc []
225+
m <- runNoLogging $ ghcPkgDump menv Ghc []
227226
$ conduitDumpPackage
228227
=$ addProfiling icache
229228
=$ addHaddock icache

stack-nightly.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ nix:
77
- http-client-tls-0.3.4
88
extra-deps:
99
- bindings-uname-0.1
10+
- unliftio-0.2.0.0

stack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ extra-deps:
2626
- extra-1.6
2727
- hsc2hs-0.68.2
2828
- hpack-0.20.0
29+
- unliftio-0.2.0.0

0 commit comments

Comments
 (0)