Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MonadDeclare more useful #100

Merged
merged 9 commits into from
Apr 25, 2017
12 changes: 7 additions & 5 deletions src/Data/Swagger/Declare.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
Expand All @@ -17,7 +18,9 @@ import Prelude.Compat
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Cont (ContT)
import Control.Monad.Error (Error, ErrorT)
#if __GLASGOW_HASKELL__ >= 710
import Control.Monad.Except (ExceptT)
#endif
import Control.Monad.List (ListT)
import Control.Monad.Reader (ReaderT)
import Control.Monad.Trans.Identity (IdentityT)
Expand Down Expand Up @@ -151,12 +154,11 @@ instance MonadDeclare d m => MonadDeclare d (ContT r m) where
declare = lift . declare
look = lift look

-- Note: deprecated, fails with -Wall
instance (Error e, MonadDeclare d m) => MonadDeclare d (ErrorT e m) where
#if __GLASGOW_HASKELL__ >= 710
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should depend on transformers-compat >= 0.3 (if we don't), then ExceptT will always be there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Control.Monad.Trans.Except

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I forgot about transformers-compat.

instance MonadDeclare d m => MonadDeclare d (ExceptT e m) where
declare = lift . declare
look = lift look

-- Note: ExceptT not provided because it is not available in ghc 7.8.
#endif

instance MonadDeclare d m => MonadDeclare d (IdentityT m) where
declare = lift . declare
Expand Down