ekmett / exceptions

mtl friendly exceptions
Other
49 stars 32 forks source link

transformers-0.6 support #82

Closed phadej closed 2 years ago

phadej commented 3 years ago
Building library for exceptions-0.10.4..

src/Control/Monad/Catch.hs:91:8:
    Could not find module ‘Control.Monad.Trans.List’
    It is a member of the hidden package ‘transformers-0.4.2.0@trans_GZTjP9K5WFq01xC9BAGQpF’.
    Perhaps you need to add ‘transformers’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

src/Control/Monad/Catch.hs:93:8:
    Could not find module ‘Control.Monad.Trans.Error’

This is blocked on mtl lifting bounds, preliminary patch would be

diff --git a/exceptions.cabal b/exceptions.cabal
index c8028f2..15ec945 100644
--- a/exceptions.cabal
+++ b/exceptions.cabal
@@ -49,14 +49,14 @@ library
     base                       >= 4.3      && < 5,
     stm                        >= 2.2      && < 3,
     template-haskell           >= 2.2      && < 2.19,
-    mtl                        >= 2.0      && < 2.3
+    mtl                        >= 2.0      && < 2.4

   if !impl(ghc >= 8.0)
     build-depends: fail        == 4.9.*

   if flag(transformers-0-4)
     build-depends:
-      transformers             >= 0.4      && < 0.6
+      transformers             >= 0.4      && < 0.7
   else
     build-depends:
       transformers             >= 0.2      && < 0.4,
diff --git a/src/Control/Monad/Catch.hs b/src/Control/Monad/Catch.hs
index 148b341..f219526 100644
--- a/src/Control/Monad/Catch.hs
+++ b/src/Control/Monad/Catch.hs
@@ -88,14 +88,17 @@ import qualified Control.Monad.Trans.Writer.Lazy as LazyW
 import qualified Control.Monad.Trans.Writer.Strict as StrictW
 import Control.Monad.ST (ST)
 import Control.Monad.STM (STM)
-import Control.Monad.Trans.List (ListT(..), runListT)
 import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
-import Control.Monad.Trans.Error (ErrorT(..), Error, runErrorT)
 import Control.Monad.Trans.Except (ExceptT(..), runExceptT)
 import Control.Monad.Trans.Cont (ContT)
 import Control.Monad.Trans.Identity
 import Control.Monad.Reader as Reader

+#if !(MIN_VERSION_transformers(0,6,0))
+import Control.Monad.Trans.List (ListT(..), runListT)
+import Control.Monad.Trans.Error (ErrorT(..), Error, runErrorT)
+#endif
+
 import Language.Haskell.TH.Syntax (Q)

 #if MIN_VERSION_base(4,4,0)
@@ -598,10 +601,12 @@ instance (MonadMask m, Monoid w) => MonadMask (StrictRWS.RWST r w s m) where
     return ((b, c), s3, w123)

 -- Transformers which are only instances of MonadThrow and MonadCatch, not MonadMask
+#if !(MIN_VERSION_transformers(0,6,0))
 instance MonadThrow m => MonadThrow (ListT m) where
   throwM = lift . throwM
 instance MonadCatch m => MonadCatch (ListT m) where
   catch (ListT m) f = ListT $ catch m (runListT . f)
+#endif

 -- | Throws exceptions into the base monad.
 instance MonadThrow m => MonadThrow (MaybeT m) where
@@ -639,6 +644,7 @@ instance MonadMask m => MonadMask (MaybeT m) where
     return ((,) <$> eb <*> ec)

 -- | Throws exceptions into the base monad.
+#if !(MIN_VERSION_transformers(0,6,0))
 instance (Error e, MonadThrow m) => MonadThrow (ErrorT e m) where
   throwM = lift . throwM
 -- | Catches exceptions from the base monad.
@@ -673,6 +679,7 @@ instance (Error e, MonadMask m) => MonadMask (ErrorT e m) where
       c <- ec
       b <- eb
       return (b, c)
+#endif

 -- | Throws exceptions into the base monad.
 instance MonadThrow m => MonadThrow (ExceptT e m) where
phadej commented 2 years ago

Ping, there is mtl release candidate https://hackage.haskell.org/package/mtl-2.3/candidate

RyanGlScott commented 2 years ago

I've created an mtl-2.3 branch which supports transformers-0.6.* and mtl-2.3.*. (I've also created mtl-2.3 branches for all Kmettiverse dependencies up to lens if you're wanting to test them.) I'd like to wait until the final mtl-2.3 release before uploading new releases to Hackage, however, just in case there are any last-minute mtl changes.

phadej commented 2 years ago

@RyanGlScott great, thanks!

RyanGlScott commented 2 years ago

I've uploaded exceptions-0.10.5 to Hackage with a fix.