ether 0.4.0.1 → 0.4.0.2
raw patch · 5 files changed
+69/−7 lines, 5 filesdep ~basedep ~transformers-liftPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, transformers-lift
API changes (from Hackage documentation)
- Control.Monad.Trans.Ether.Writer: listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)
+ Control.Monad.Trans.Ether.Writer: listen :: (Monad m, Monoid w) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)
- Control.Monad.Trans.Ether.Writer: pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
+ Control.Monad.Trans.Ether.Writer: pass :: (Monad m, Monoid w) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
Files
- ether.cabal +6/−5
- src/Control/Ether/TH.hs +5/−0
- src/Control/Monad/Trans/Ether/Writer.hs +14/−2
- test/Regression.hs +2/−0
- test/Regression/T10.hs +42/−0
ether.cabal view
@@ -1,11 +1,11 @@ name: ether-version: 0.4.0.1+version: 0.4.0.2 synopsis: Monad transformers and classes description: Ether is a Haskell library that extends @mtl@ and @transformers@ with tagged monad transformers and classes in a compatible way. - Introduction https://int-index.github.io/ether/+ Introduction <https://int-index.github.io/ether/> category: Control license: BSD3@@ -58,9 +58,9 @@ other-modules: Control.Ether.Util - build-depends: base >=4.7 && <4.9+ build-depends: base >=4.7 && <4.10 , transformers >=0.4.2- , transformers-lift >=0.1+ , transformers-lift >=0.1.0.1 , mtl >=2.2.1 , mmorph >=1.0.4 , monad-control >=1.0.0.4@@ -90,7 +90,7 @@ test-suite regression - build-depends: base >=4.7 && <4.9+ build-depends: base >=4.7 && <4.10 , transformers >=0.4.2 , mtl >=2.2.1 , tasty >=0.10@@ -108,6 +108,7 @@ Regression.T7 Regression.T8 Regression.T9+ Regression.T10 type: exitcode-stdio-1.0 hs-source-dirs: test
src/Control/Ether/TH.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP #-} -- | Template Haskell utilities. @@ -11,7 +12,11 @@ import Data.Proxy emptyDataDecl :: TH.Name -> TH.DecQ+#if __GLASGOW_HASKELL__ < 800 emptyDataDecl name = TH.dataD (return []) name [] [] []+#else+emptyDataDecl name = TH.dataD (return []) name [] Nothing [] (return [])+#endif funSimple :: TH.Name -> TH.ExpQ -> TH.DecQ funSimple name body = TH.funD name [ TH.clause [] (TH.normalB body) [] ]
src/Control/Monad/Trans/Ether/Writer.hs view
@@ -84,10 +84,22 @@ tell t w = writer t ((), w) -- | Executes an action and adds its accumulator to the value of the computation.-listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)+listen+#if __GLASGOW_HASKELL__ < 800+ :: (Monad m, Monoid w)+#else+ :: Monad m+#endif+ => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w) listen _ = pack . Trans.listen . unpack -- | Executes an action which returns a value and a function, and returns the -- value, applying the function to the accumulator.-pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a+pass+#if __GLASGOW_HASKELL__ < 800+ :: (Monad m, Monoid w)+#else+ :: Monad m+#endif+ => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a pass _ = pack . Trans.pass . unpack
test/Regression.hs view
@@ -11,6 +11,7 @@ import Regression.T7 import Regression.T8 import Regression.T9+import Regression.T10 main :: IO () main = defaultMain suite@@ -26,4 +27,5 @@ , test7 , test8 , test9+ , test10 ]
+ test/Regression/T10.hs view
@@ -0,0 +1,42 @@+module Regression.T10 (test10) where++import Control.Applicative+import Data.Functor.Identity+import qualified Control.Monad.Ether.Implicit as I++import Test.Tasty+import Test.Tasty.QuickCheck++testEther :: Integer -> I.StateT Integer Maybe [Integer]+testEther m = range+ where+ range = liftA2 (:) yield (range <|> pure [])+ yield = I.stateT $ \n -> do+ I.guard (n <= m)+ Just (n, n + 1)++testEther' :: Integer -> I.State Integer [Integer]+testEther' m =+ I.stateT $ Identity . maybe ([], m + 1) id . I.runStateT (testEther m)++next1 :: Integer -> Integer -> Maybe Integer+next1 m n+ | n <= m = Just (m + 1)+ | otherwise = Nothing++range1 :: Integer -> Integer -> Maybe [Integer]+range1 m n+ | n <= m = Just [n..m]+ | otherwise = Nothing++test10 :: TestTree+test10 = testGroup "T10: Alternative instance"+ [ testProperty "execStateT works"+ $ \m n -> I.execStateT (testEther m) n == next1 m n+ , testProperty "evalStateT works"+ $ \m n -> I.evalStateT (testEther m) n == range1 m n+ , testProperty "execState works"+ $ \m n -> I.execState (testEther' m) n == m + 1+ , testProperty "evalState works"+ $ \m n -> I.evalState (testEther' m) n == [n..m]+ ]