Skip to content

Commit ee4fad2

Browse files
committed
Switch to unliftio package
1 parent 3a4f7e5 commit ee4fad2

76 files changed

Lines changed: 174 additions & 466 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Control/Concurrent/Execute.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ module Control.Concurrent.Execute
1111
) where
1212

1313
import Control.Applicative
14-
import Control.Concurrent.Async (Concurrently (..), async)
1514
import Control.Concurrent.STM
16-
import Control.Exception (mask)
1715
import Control.Monad (join, unless)
18-
import Control.Monad.IO.Unlift
16+
import Stack.Prelude
1917
import Data.Foldable (sequenceA_)
2018
import Data.Set (Set)
2119
import qualified Data.Set as Set

src/Control/Monad/IO/Unlift.hs

Lines changed: 0 additions & 236 deletions
This file was deleted.

src/Data/IORef/RunOnce.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module Data.IORef.RunOnce (runOnce) where
22

3-
import Control.Monad.IO.Unlift
4-
import Data.IORef
3+
import Stack.Prelude
54

65
runOnce :: (MonadUnliftIO m, MonadIO n) => m a -> m (n a)
7-
runOnce f = withRunIO $ \runIO -> do
6+
runOnce f = withRunInIO $ \run -> do
87
ref <- newIORef Nothing
98
return $ liftIO $ do
109
mval <- readIORef ref
1110
case mval of
1211
Just val -> return val
1312
Nothing -> do
14-
val <- runIO f
13+
val <- run f
1514
writeIORef ref (Just val)
1615
return val

src/Data/Store/VersionTagged.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Data.Store.VersionTagged
1515
) where
1616

1717
import Control.Applicative
18-
import Control.Monad.IO.Unlift
18+
import Stack.Prelude
1919
import Control.Monad.Logger
2020
import qualified Data.ByteString as BS
2121
import Data.Data (Data)

src/Network/HTTP/Download.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Network.HTTP.Download
2121
) where
2222

2323
import Control.Monad (void)
24-
import Control.Monad.IO.Unlift
24+
import Stack.Prelude
2525
import Control.Monad.Logger (MonadLogger, logDebug)
2626
import qualified Data.ByteString.Lazy as L
2727
import Data.Conduit (runConduit, (.|), yield)
@@ -41,8 +41,6 @@ import Path (Abs, File, Path, toFilePath)
4141
import System.Directory (createDirectoryIfMissing,
4242
removeFile)
4343
import System.FilePath (takeDirectory, (<.>))
44-
import System.IO (IOMode (ReadMode),
45-
withBinaryFile)
4644

4745
-- | Download the given URL to the given location. If the file already exists,
4846
-- no download is performed. Otherwise, creates the parent directory, downloads

src/Network/HTTP/Download/Verified.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import qualified Data.Text.Encoding as Text
3030

3131
import Control.Applicative
3232
import Control.Monad
33-
import Control.Monad.Catch (Handler (..))
34-
import Control.Monad.IO.Unlift hiding (Handler (..)) -- FIXME when safe-exceptions uses exceptions's Handler, we can get rid of this and the dependency on exceptions
33+
import Control.Monad.Catch (Handler (..)) -- would be nice if retry exported this itself
34+
import Stack.Prelude hiding (Handler (..))
3535
import Control.Monad.Logger (logDebug, MonadLogger)
3636
import Control.Retry (recovering,limitRetries,RetryPolicy,constantDelay)
3737
import Crypto.Hash
@@ -56,7 +56,7 @@ import Path
5656
import Prelude -- Fix AMP warning
5757
import System.Directory
5858
import qualified System.FilePath as FP ((<.>))
59-
import System.IO
59+
import System.IO (hFileSize)
6060

6161
-- | A request together with some checks to perform.
6262
data DownloadRequest = DownloadRequest
@@ -197,7 +197,7 @@ recoveringHttp retryPolicy =
197197
helper $ recovering retryPolicy handlers
198198
#endif
199199
where
200-
helper wrapper action = withRunIO $ \run -> wrapper (run action)
200+
helper wrapper action = withRunInIO $ \run -> wrapper (run action)
201201

202202
handlers = [const $ Handler alwaysRetryHttp,const $ Handler retrySomeIO]
203203

@@ -263,7 +263,7 @@ verifiedDownload DownloadRequest{..} destpath progressSink = do
263263
`catch` \(_ :: VerifyFileException) -> return False)
264264
`catch` \(_ :: VerifiedDownloadException) -> return False
265265

266-
checkExpectations = bracket (openFile fp ReadMode) hClose $ \h -> do
266+
checkExpectations = withBinaryFile fp ReadMode $ \h -> do
267267
for_ drLengthCheck $ checkFileSizeExpectations h
268268
sourceHandle h $$ getZipSink (hashChecksToZipSink drRequest drHashChecks)
269269

src/Path/Extra.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import qualified Data.ByteString.Char8 as BS
2020
import qualified Data.Text as T
2121
import qualified Data.Text.Encoding as T
2222
import Control.Monad (liftM)
23-
import Control.Monad.IO.Unlift
23+
import Stack.Prelude
2424
import Data.Bool (bool)
2525
import Path
2626
import Path.IO

src/Path/Find.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Path.Find
1111

1212
import Control.DeepSeq (force)
1313
import Control.Monad
14-
import Control.Monad.IO.Unlift
14+
import Stack.Prelude
1515
import System.IO.Error (isPermissionError)
1616
import Data.List
1717
import Path

src/Stack/Build.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Stack.Build
2121
where
2222

2323
import Control.Monad
24-
import Control.Monad.IO.Unlift
24+
import Stack.Prelude
2525
import Control.Monad.Logger
2626
import Control.Monad.Reader (MonadReader)
2727
import Data.Aeson (Value (Object, Array), (.=), object)
@@ -64,7 +64,6 @@ import Stack.Types.Package
6464
import Stack.Types.PackageIdentifier
6565
import Stack.Types.PackageName
6666
import Stack.Types.StackT
67-
import Stack.Types.StringError
6867
import Stack.Types.Version
6968

7069
#ifdef WINDOWS
@@ -292,7 +291,7 @@ withLoadPackage inner = do
292291
econfig <- view envConfigL
293292
menv <- getMinimalEnvOverride
294293
root <- view projectRootL
295-
run <- askRunIO
294+
run <- askRunInIO
296295
withCabalLoader $ \loadFromIndex ->
297296
inner $ \loc flags ghcOptions -> do
298297
bs <- run $ loadSingleRawCabalFile loadFromIndex menv root loc
@@ -385,7 +384,7 @@ queryBuildInfo selectors0 =
385384
_ -> err $ "Cannot apply selector to " ++ show value
386385
where
387386
cont = select (front . (sel:)) sels
388-
err msg = errorString $ msg ++ ": " ++ show (front [sel])
387+
err msg = throwString $ msg ++ ": " ++ show (front [sel])
389388

390389
-- | Get the raw build information object
391390
rawBuildInfo :: (StackM env m, HasEnvConfig env) => m Value

src/Stack/Build/Cache.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Stack.Build.Cache
3434
import Control.Applicative
3535
import Control.DeepSeq (NFData)
3636
import Control.Monad (liftM)
37-
import Control.Monad.IO.Unlift
37+
import Stack.Prelude
3838
import Control.Monad.Logger (MonadLogger)
3939
import Control.Monad.Reader (MonadReader)
4040
import Crypto.Hash (hashWith, SHA256(..))

0 commit comments

Comments
 (0)