on master help sign in
Merge pull request #1 from neongreen/master

GHC 7.8 compatibility

commitafc2416d4918b860a68faa329168d65a88454d01 authorIndex Int <vlad.z.4096@gmail.com> dateSun 14 Jun 2015, 03:51 (11 years ago) parenteabeb809673445
16 files changed+91−18
.travis.yml+1 CHANGELOG.md+1 ether.cabal+5−4 src/Control/Ether/Util.hs+19 src/Control/Ether/Wrapped.hs+1−1 src/Control/Monad/Ether/Except/Class.hs+11 src/Control/Monad/Ether/Implicit/Except/TH.hs+1−1 src/Control/Monad/Ether/Reader/Class.hs+13−1 src/Control/Monad/Ether/State/Class.hs+13−1 src/Control/Monad/Ether/Writer/Class.hs+11 src/Control/Monad/Trans/Ether/Except.hs+1−1 src/Control/Monad/Trans/Ether/Reader.hs+1−1 src/Control/Monad/Trans/Ether/State/Lazy.hs+1−1 src/Control/Monad/Trans/Ether/State/Strict.hs+1−1 src/Control/Monad/Trans/Ether/Writer.hs+6−1 test/Regression.hs+5−5
.travis.yml+1
@@ -1,4 +1,5 @@
11env:
2+ - CABALVER=1.18 GHCVER=7.8.4
23 - CABALVER=1.22 GHCVER=7.10.2
34 - CABALVER=head GHCVER=head
45
CHANGELOG.md+1
@@ -3,3 +3,4 @@
33
44* Fix `transformers` lower bound.
55* Remove unused language extensions.
6+* GHC 7.8 compatibility.
ether.cabal+5−4
@@ -13,7 +13,7 @@ maintainer: Index Int <vlad.z.4096@gmail.com>
1313homepage: https://int-index.github.io/ether/
1414bug-reports: https://github.com/int-index/ether/issues
1515build-type: Simple
16−cabal-version: >=1.22
16+cabal-version: >=1.18
1717extra-source-files: CHANGELOG.md
1818
1919source-repository head
@@ -53,10 +53,10 @@ library
5353
5454 other-modules: Control.Ether.Util
5555
56− build-depends: base >=4.8 && <4.9
56+ build-depends: base >=4.7 && <4.9
5757 , transformers >=0.4.2
5858 , mtl >=2.2.1
59− , template-haskell >=2.10
59+ , template-haskell >=2.9
6060 , newtype-generics >=0.4.1
6161
6262 default-language: Haskell2010
@@ -74,6 +74,7 @@ library
7474 PolyKinds
7575 TypeOperators
7676 DefaultSignatures
77+ CPP
7778
7879 hs-source-dirs: src
7980 ghc-options: -Wall
@@ -81,7 +82,7 @@ library
8182
8283test-suite regression
8384
84− build-depends: base >=4.8 && <4.9
85+ build-depends: base >=4.7 && <4.9
8586 , transformers >=0.4.2
8687 , mtl >=2.2.1
8788 , tasty >=0.10
src/Control/Ether/Util.hs+19
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE PolyKinds #-}
34{-# LANGUAGE TypeOperators #-}
@@ -8,11 +9,19 @@ module Control.Ether.Util
89 , liftPass_WriterT
910 , type (++)
1011 , MaybeToList
12+ , fmap
1113 ) where
1214
1315import qualified Control.Monad.Signatures as Sig
1416import qualified Control.Monad.Trans.Except as Trans
1517import qualified Control.Monad.Trans.Writer as Trans
18+import Prelude hiding (fmap)
19+
20+#if __GLASGOW_HASKELL__ < 710
21+import qualified Control.Monad
22+#else
23+import qualified Prelude
24+#endif
1625
1726type family (as :: [*]) ++ (bs :: [*]) :: [*] where
1827 '[] ++ bs = bs
@@ -36,3 +45,13 @@ liftPass_WriterT :: Monad m => Sig.Pass w' m (a, w) -> Sig.Pass w' (Trans.Writer
3645liftPass_WriterT pass m = Trans.WriterT $ pass $ do
3746 ~((a, f), w) <- Trans.runWriterT m
3847 return ((a, w), f)
48+
49+#if __GLASGOW_HASKELL__ < 710
50+fmap :: Monad f => (a -> b) -> f a -> f b
51+fmap = Control.Monad.liftM
52+#else
53+fmap :: Functor f => (a -> b) -> f a -> f b
54+fmap = Prelude.fmap
55+#endif
56+
57+{-# INLINE fmap #-}
src/Control/Ether/Wrapped.hs+1−1
@@ -27,7 +27,7 @@ module Control.Ether.Wrapped
2727 ) where
2828
2929import Data.Proxy (Proxy(Proxy))
30−import Control.Applicative (Alternative)
30+import Control.Applicative
3131import Control.Monad (MonadPlus)
3232import Control.Monad.Fix (MonadFix)
3333import Control.Monad.IO.Class (MonadIO)
src/Control/Monad/Ether/Except/Class.hs+11
@@ -1,14 +1,25 @@
1+{-# OPTIONS_GHC -fno-warn-unrecognised-pragmas #-}
2+
3+{-# LANGUAGE CPP #-}
14{-# LANGUAGE MultiParamTypeClasses #-}
25{-# LANGUAGE FlexibleInstances #-}
36{-# LANGUAGE UndecidableInstances #-}
47{-# LANGUAGE FunctionalDependencies #-}
58
9+#if __GLASGOW_HASKELL__ < 710
10+{-# LANGUAGE OverlappingInstances #-}
11+#endif
12+
613-- | See "Control.Monad.Except".
714
815module Control.Monad.Ether.Except.Class
916 ( MonadExcept(..)
1017 ) where
1118
19+#if __GLASGOW_HASKELL__ < 710
20+import Data.Monoid
21+#endif
22+
1223import Data.Proxy (Proxy(Proxy))
1324import Control.Monad.Trans (lift)
1425
src/Control/Monad/Ether/Implicit/Except/TH.hs+1−1
@@ -10,7 +10,7 @@ import Control.Monad.Ether.Implicit.Except
1010
1111-- | Basic building block for 'try'. Runs an 'ExceptT' with a handler.
1212try' :: Functor m => ExceptT e m a -> (e -> a) -> m a
13−try' m h = either h id <$> runExceptT m
13+try' m h = fmap (either h id) (runExceptT m)
1414
1515-- | Handle @n@ exceptions with supplied handlers.
1616--
src/Control/Monad/Ether/Reader/Class.hs+13−1
@@ -1,8 +1,15 @@
1+{-# OPTIONS_GHC -fno-warn-unrecognised-pragmas #-}
2+
3+{-# LANGUAGE CPP #-}
14{-# LANGUAGE MultiParamTypeClasses #-}
25{-# LANGUAGE FlexibleInstances #-}
36{-# LANGUAGE UndecidableInstances #-}
47{-# LANGUAGE FunctionalDependencies #-}
58
9+#if __GLASGOW_HASKELL__ < 710
10+{-# LANGUAGE OverlappingInstances #-}
11+#endif
12+
613-- | See "Control.Monad.Reader.Class".
714
815module Control.Monad.Ether.Reader.Class
@@ -10,6 +17,10 @@ module Control.Monad.Ether.Reader.Class
1017 , asks
1118 ) where
1219
20+#if __GLASGOW_HASKELL__ < 710
21+import Data.Monoid
22+#endif
23+
1324import Data.Proxy (Proxy(Proxy))
1425import Control.Monad.Trans (lift)
1526
@@ -19,6 +30,7 @@ import Control.Monad.Trans.Ether.Reader hiding (reader, ask, local)
1930import qualified Control.Monad.Trans.Ether.Reader as R
2031import qualified Control.Monad.Trans.Ether.State.Lazy as S.L
2132import qualified Control.Monad.Trans.Ether.State.Strict as S.S
33+import qualified Control.Ether.Util as Util
2234
2335-- for mtl instances
2436import qualified Control.Monad.Trans.Cont as Trans (ContT , liftLocal)
@@ -56,7 +68,7 @@ class Monad m => MonadReader tag r m | m tag -> r where
5668 -> (r -> a)
5769 -- ^ The selector function to apply to the environment.
5870 -> m a
59− reader t f = fmap f (ask t)
71+ reader t f = Util.fmap f (ask t)
6072
6173-- | Retrieves a function of the current environment.
6274asks
src/Control/Monad/Ether/State/Class.hs+13−1
@@ -1,8 +1,15 @@
1+{-# OPTIONS_GHC -fno-warn-unrecognised-pragmas #-}
2+
3+{-# LANGUAGE CPP #-}
14{-# LANGUAGE MultiParamTypeClasses #-}
25{-# LANGUAGE FlexibleInstances #-}
36{-# LANGUAGE UndecidableInstances #-}
47{-# LANGUAGE FunctionalDependencies #-}
58
9+#if __GLASGOW_HASKELL__ < 710
10+{-# LANGUAGE OverlappingInstances #-}
11+#endif
12+
613-- | See "Control.Monad.State.Class".
714
815module Control.Monad.Ether.State.Class
@@ -11,6 +18,10 @@ module Control.Monad.Ether.State.Class
1118 , gets
1219 ) where
1320
21+#if __GLASGOW_HASKELL__ < 710
22+import Data.Monoid
23+#endif
24+
1425import Control.Monad.Trans (lift)
1526
1627import Control.Monad.Trans.Ether.Reader (ReaderT)
@@ -18,6 +29,7 @@ import Control.Monad.Trans.Ether.Writer (WriterT)
1829import Control.Monad.Trans.Ether.Except (ExceptT)
1930import qualified Control.Monad.Trans.Ether.State.Lazy as S.L
2031import qualified Control.Monad.Trans.Ether.State.Strict as S.S
32+import qualified Control.Ether.Util as Util
2133
2234-- for mtl instances
2335import qualified Control.Monad.Trans.Cont as Trans (ContT)
@@ -58,7 +70,7 @@ modify t f = state t (\s -> ((), f s))
5870
5971-- | Gets specific component of the state, using a projection function supplied.
6072gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a
61−gets t f = fmap f (get t)
73+gets t f = Util.fmap f (get t)
6274
6375instance {-# OVERLAPPING #-} Monad m => MonadState tag s (S.L.StateT tag s m) where
6476 get = S.L.get
src/Control/Monad/Ether/Writer/Class.hs+11
@@ -1,8 +1,15 @@
1+{-# OPTIONS_GHC -fno-warn-unrecognised-pragmas #-}
2+
3+{-# LANGUAGE CPP #-}
14{-# LANGUAGE MultiParamTypeClasses #-}
25{-# LANGUAGE FlexibleInstances #-}
36{-# LANGUAGE UndecidableInstances #-}
47{-# LANGUAGE FunctionalDependencies #-}
58
9+#if __GLASGOW_HASKELL__ < 710
10+{-# LANGUAGE OverlappingInstances #-}
11+#endif
12+
613-- | See "Control.Monad.Writer.Class".
714
815module Control.Monad.Ether.Writer.Class
@@ -11,6 +18,10 @@ module Control.Monad.Ether.Writer.Class
1118 , censor
1219 ) where
1320
21+#if __GLASGOW_HASKELL__ < 710
22+import Data.Monoid
23+#endif
24+
1425import Data.Proxy (Proxy(Proxy))
1526import Control.Monad.Trans (lift)
1627
src/Control/Monad/Trans/Ether/Except.hs+1−1
@@ -32,7 +32,7 @@ module Control.Monad.Trans.Ether.Except
3232import Data.Proxy (Proxy(Proxy))
3333import Data.Functor.Identity (Identity(..))
3434import Data.Coerce (coerce)
35−import Control.Applicative (Alternative)
35+import Control.Applicative
3636import Control.Monad (MonadPlus)
3737import Control.Monad.Fix (MonadFix)
3838import Control.Monad.Trans.Class (MonadTrans, lift)
src/Control/Monad/Trans/Ether/Reader.hs+1−1
@@ -31,7 +31,7 @@ module Control.Monad.Trans.Ether.Reader
3131import Data.Proxy (Proxy(Proxy))
3232import Data.Functor.Identity (Identity(..))
3333import Data.Coerce (coerce)
34−import Control.Applicative (Alternative)
34+import Control.Applicative
3535import Control.Monad (MonadPlus)
3636import Control.Monad.Fix (MonadFix)
3737import Control.Monad.Trans.Class (MonadTrans, lift)
src/Control/Monad/Trans/Ether/State/Lazy.hs+1−1
@@ -36,7 +36,7 @@ module Control.Monad.Trans.Ether.State.Lazy
3636import Data.Proxy (Proxy(Proxy))
3737import Data.Functor.Identity (Identity(..))
3838import Data.Coerce (coerce)
39−import Control.Applicative (Alternative)
39+import Control.Applicative
4040import Control.Monad (MonadPlus)
4141import Control.Monad.Fix (MonadFix)
4242import Control.Monad.Trans.Class (MonadTrans, lift)
src/Control/Monad/Trans/Ether/State/Strict.hs+1−1
@@ -36,7 +36,7 @@ module Control.Monad.Trans.Ether.State.Strict
3636import Data.Proxy (Proxy(Proxy))
3737import Data.Functor.Identity (Identity(..))
3838import Data.Coerce (coerce)
39−import Control.Applicative (Alternative)
39+import Control.Applicative
4040import Control.Monad (MonadPlus)
4141import Control.Monad.Fix (MonadFix)
4242import Control.Monad.Trans.Class (MonadTrans, lift)
src/Control/Monad/Trans/Ether/Writer.hs+6−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DeriveGeneric #-}
23{-# LANGUAGE MultiParamTypeClasses #-}
34{-# LANGUAGE TypeFamilies #-}
@@ -32,10 +33,14 @@ module Control.Monad.Trans.Ether.Writer
3233 , liftPass
3334 ) where
3435
36+#if __GLASGOW_HASKELL__ < 710
37+import Data.Monoid
38+#endif
39+
3540import Data.Proxy (Proxy(Proxy))
3641import Data.Functor.Identity (Identity(..))
3742import Data.Coerce (coerce)
38−import Control.Applicative (Alternative)
43+import Control.Applicative
3944import Control.Monad (MonadPlus)
4045import Control.Monad.Fix (MonadFix)
4146import Control.Monad.Trans.Class (MonadTrans, lift)
test/Regression.hs+5−5
@@ -9,7 +9,7 @@ module Main where
99
1010import Data.Functor.Identity
1111import Data.Monoid
12−import Data.Foldable
12+import Control.Monad
1313import Control.Ether.Tagged
1414import Control.Ether.TH
1515import Control.Ether.Wrapped
@@ -182,7 +182,7 @@ try3 = $(try 3)
182182exceptCore' :: Double -> Double -> String
183183exceptCore' a b = runIdentity $ do
184184 $(try 2)
185− (show <$> exceptCore a b)
185+ (liftM show (exceptCore a b))
186186 (\(NegativeLog (x::Double)) -> "nl: " ++ show x)
187187 (\DivideByZero -> "dz")
188188
@@ -192,7 +192,7 @@ summatorCore
192192 , MonadWriter Foo (Sum a) m
193193 ) => [a] -> m ()
194194summatorCore xs = do
195− for_ xs $ \x -> do
195+ forM_ xs $ \x -> do
196196 T.tell (Sum x)
197197 tell foo (Sum 1)
198198
@@ -200,10 +200,10 @@ summatorCore' :: Num a => [a] -> (Sum a, Sum a)
200200summatorCore' = runWriter foo . T.execWriterT . summatorCore
201201
202202wrapState_f :: T.MonadState Int m => m String
203−wrapState_f = fmap show T.get
203+wrapState_f = liftM show T.get
204204
205205wrapState_g :: T.MonadState Bool m => m String
206−wrapState_g = fmap show T.get
206+wrapState_g = liftM show T.get
207207
208208wrapState_useboth
209209 :: ( MonadState Foo Int m