Commit 08bac7ad authored by Heneli Kailahi's avatar Heneli Kailahi
Browse files

Added MonadUnliftIO instance for ContextT.

parent 0966581d
-- This file has been generated from package.yaml by hpack version 0.20.0.
-- This file has been generated from package.yaml by hpack version 0.27.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 0e7b65fc80c01f09bbc6c5d29da7e17ba09561542cffc9f1780105d9c863f54d
-- hash: b746e53a0cfe97d0438e3622bc5cfa0dda9a6e4a0d8d8e0c667a18eea98cf70a
name: composite-base
version: 0.5.4.0
......@@ -33,6 +33,7 @@ library
, text >=1.2.2.2 && <1.3
, transformers >=0.5.2.0 && <0.6
, transformers-base >=0.4.4 && <0.5
, unliftio-core >=0.1.0.0 && <0.2.0.0
, vinyl >=0.5.3 && <0.8
exposed-modules:
Composite
......@@ -65,6 +66,7 @@ test-suite composite-base-test
, text >=1.2.2.2 && <1.3
, transformers >=0.5.2.0 && <0.6
, transformers-base >=0.4.4 && <0.5
, unliftio-core >=0.1.0.0 && <0.2.0.0
, vinyl >=0.5.3 && <0.8
other-modules:
RecordSpec
......
{ mkDerivation, base, exceptions, hspec, lens, monad-control, mtl
, profunctors, QuickCheck, stdenv, template-haskell, text
, transformers, transformers-base, vinyl
, transformers, transformers-base, unliftio-core, vinyl
}:
mkDerivation {
pname = "composite-base";
......@@ -8,11 +8,12 @@ mkDerivation {
src = ./.;
libraryHaskellDepends = [
base exceptions lens monad-control mtl profunctors template-haskell
text transformers transformers-base vinyl
text transformers transformers-base unliftio-core vinyl
];
testHaskellDepends = [
base exceptions hspec lens monad-control mtl profunctors QuickCheck
template-haskell text transformers transformers-base vinyl
template-haskell text transformers transformers-base unliftio-core
vinyl
];
homepage = "https://github.com/ConferHealth/composite#readme";
description = "Shared utilities for composite-* packages";
......
......@@ -20,6 +20,7 @@ dependencies:
- text >= 1.2.2.2 && < 1.3
- transformers >= 0.5.2.0 && < 0.6
- transformers-base >= 0.4.4 && < 0.5
- unliftio-core >= 0.1.0.0 && < 0.2.0.0
- vinyl >= 0.5.3 && < 0.8
default-extensions:
......
......@@ -21,6 +21,7 @@ import Control.Monad.Fail (MonadFail)
import qualified Control.Monad.Fail as MonadFail
import Control.Monad.Fix (MonadFix(mfix))
import Control.Monad.IO.Class (MonadIO(liftIO))
import Control.Monad.IO.Unlift (askUnliftIO, MonadUnliftIO, UnliftIO(UnliftIO), unliftIO, withUnliftIO, withRunInIO)
import Control.Monad.Reader (ReaderT(ReaderT), runReaderT)
import Control.Monad.Reader.Class (MonadReader(local, ask, reader))
import qualified Control.Monad.RWS.Lazy as Lazy
......@@ -162,6 +163,17 @@ instance MonadBaseControl b m => MonadBaseControl b (ContextT c m) where
liftBaseWith $ \ runInBase ->
f (runInBase . ($ c) . runContextT)
instance MonadUnliftIO m => MonadUnliftIO (ContextT c m) where
{-# INLINE askUnliftIO #-}
askUnliftIO = ContextT $ \c ->
withUnliftIO $ \u ->
return (UnliftIO (unliftIO u . flip runContextT c))
{-# INLINE withRunInIO #-}
withRunInIO inner =
ContextT $ \c ->
withRunInIO $ \run ->
inner (run . flip runContextT c)
instance MonadReader r m => MonadReader r (ContextT c m) where
ask = lift ask
local = mapContextT . local
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment