on master help sign in
Allow for unliftio-core 0.2's breaking changes

I much prefer either allowing for newer versions via CPP or if that's impractical, dropping support for the older version of a dependency than instituting upper bounds. Upper bounds in my opinion just make your library more likely to stall out on an old version of a dependency or create tons of busy work by forcing you to constantly poke upper bounds that don't end up being necessary for the upgrade. cc #117

commit5238b4c4ad45c79b76fe7ced87d18698243f2aa8 authorMichael Xavier <michael@michaelxavier.net> dateFri 27 Mar 2020, 13:06 (7 years ago) parent88ca49a
3 files changed+25−7
katip/src/Katip/Core.hs+7−2 katip/src/Katip/Monadic.hs+16−4 stack.yaml+2−1
katip/src/Katip/Core.hs+7−2
@@ -901,9 +901,14 @@ instance (MonadBaseControl b m) => MonadBaseControl b (KatipT m) where
901901 restoreM = defaultRestoreM
902902
903903instance MonadUnliftIO m => MonadUnliftIO (KatipT m) where
904+#if MIN_VERSION_unliftio_core(0, 2, 0)
905+ withRunInIO inner = KatipT $ ReaderT $ \le -> withRunInIO $ \run ->
906+ inner (run . runKatipT le)
907+#else
904908 askUnliftIO = KatipT $
905− withUnliftIO $ \u ->
906− pure (UnliftIO (unliftIO u . unKatipT))
909+ withUnliftIO $ \u ->
910+ pure (UnliftIO (unliftIO u . unKatipT))
911+#endif
907912
908913#if MIN_VERSION_base(4, 9, 0)
909914instance MF.MonadFail m => MF.MonadFail (KatipT m) where
katip/src/Katip/Monadic.hs+16−4
@@ -395,9 +395,15 @@ instance (MonadIO m) => KatipContext (KatipContextT m) where
395395 localKatipNamespace f (KatipContextT m) = KatipContextT $ local (\s -> s { ltsNamespace = f (ltsNamespace s)}) m
396396
397397instance MonadUnliftIO m => MonadUnliftIO (KatipContextT m) where
398+#if MIN_VERSION_unliftio_core(0, 2, 0)
399+ withRunInIO inner = KatipContextT $ ReaderT $ \lts -> withRunInIO $ \run ->
400+ inner (run . runKatipContextT (ltsLogEnv lts) (ltsContext lts) (ltsNamespace lts))
401+#else
398402 askUnliftIO = KatipContextT $
399− withUnliftIO $ \u ->
400− pure (UnliftIO (unliftIO u . unKatipContextT))
403+ withUnliftIO $ \u ->
404+ pure (UnliftIO (unliftIO u . unKatipContextT))
405+#endif
406+
401407
402408#if MIN_VERSION_base(4, 9, 0)
403409instance MF.MonadFail m => MF.MonadFail (KatipContextT m) where
@@ -482,9 +488,15 @@ instance MonadBaseControl b m => MonadBaseControl b (NoLoggingT m) where
482488 restoreM = NoLoggingT . restoreM
483489
484490instance MonadUnliftIO m => MonadUnliftIO (NoLoggingT m) where
491+#if MIN_VERSION_unliftio_core(0, 2, 0)
492+ withRunInIO inner = NoLoggingT $ withRunInIO $ \run ->
493+ inner (run . runNoLoggingT)
494+#else
485495 askUnliftIO = NoLoggingT $
486− withUnliftIO $ \u ->
487− pure (UnliftIO (unliftIO u . runNoLoggingT))
496+ withUnliftIO $ \u ->
497+ pure (UnliftIO (unliftIO u . runNoLoggingT))
498+#endif
499+
488500
489501instance MonadIO m => Katip (NoLoggingT m) where
490502 getLogEnv = liftIO (initLogEnv "NoLoggingT" "no-logging")
stack.yaml+2−1
@@ -6,7 +6,8 @@ packages:
66 - katip-logzio
77extra-deps:
88 - bloodhound-0.16.0.0
9− - unliftio-core-0.1.2.0
9+ - unliftio-core-0.2.0.1
10+ - resourcet-1.2.3
1011flags:
1112 katip:
1213 lib-Werror: true