packages feed

state-plus 0.1 → 0.1.1

raw patch · 4 files changed

+29/−5 lines, 4 filesdep ~QuickCheckdep ~checkers

Dependency ranges changed: QuickCheck, checkers

Files

Control/Monad/Trans/State/Plus.hs view
@@ -15,6 +15,7 @@     StatePlusT, runStatePlusT, execStatePlusT, evalStatePlusT) where  import Control.Monad.State+import Control.Applicative  -- | StatePlusT behaves similar to StateT monad transformer newtype StatePlusT s m a = MkSPT { unSPT :: StateT (Bool, s) m a }@@ -32,6 +33,10 @@                             then runStateT (unSPT $ f a) s'                             else return $ (mzeroError, s') +instance (Monad m, Functor m) => Applicative (StatePlusT s m) where+    pure = return+    (<*>) = ap+ instance Monad m => MonadState s (StatePlusT s m) where     get = (MkSPT . StateT) $ \s -> return (snd s, s)     put v = (MkSPT . StateT) $ \s -> return ((), (fst s, v))@@ -48,6 +53,10 @@             bs <- runStateT (unSPT b) s             let (rr, rs) = plusStates as bs             runStateT (return rr) rs++instance (Monad m, Functor m) => Alternative (StatePlusT s m) where+    empty = mzero+    (<|>) = mplus  -- | Evaluate StatePlusT monad. In difference from runStateT it returns -- @Nothing@ if @mzero@ has been encountered. @Just a@ otherwise.
+ changelog view
@@ -0,0 +1,3 @@+0.1.1+-------+* Compatibility with QuickCheck 2.7
state-plus.cabal view
@@ -1,8 +1,8 @@ Name:                state-plus-Version:             0.1+Version:             0.1.1 License:             BSD3 License-File:        COPYING-Copyright:           Boris Sukholitko, 2012+Copyright:           Boris Sukholitko, 2014 Author:              Boris Sukholitko Maintainer:          boriss@gmail.com Cabal-version:       >= 1.8@@ -10,7 +10,12 @@ Synopsis:            MonadPlus for StateT Description:         Implements MonadPlus with left catch (MonadOr) for StateT. Category:            Control+Extra-Source-Files:  changelog+Source-Repository head+    Type: git+    Location: https://github.com/bosu/state-plus + library    build-depends:  base < 5, mtl   ghc-options:      -Wall@@ -18,7 +23,8 @@  test-suite Main   type:            exitcode-stdio-1.0-  build-depends:   base < 5, QuickCheck, mtl, state-plus, checkers+  build-depends:   base < 5, QuickCheck >= 2.7 && < 2.8, mtl, state-plus+                            , checkers >= 0.4.1 && < 0.5   ghc-options:     -Wall   hs-source-dirs:  tests   main-is:         Main.hs
tests/Main.hs view
@@ -12,8 +12,14 @@ import Data.List (foldl') import System.Exit (exitFailure) -newtype P = P Bool deriving (Eq, Arbitrary, Function, Show, CoArbitrary)-newtype SI = SI [Int] deriving (Eq, Arbitrary, Function, Show, CoArbitrary)+newtype P = P { unP :: Bool } deriving (Eq, Arbitrary, Show, CoArbitrary)+instance Function P where+    function = functionMap unP P++newtype SI = SI { unSI :: [Int] } deriving (Eq, Arbitrary, Show, CoArbitrary)+instance Function SI where+    function = functionMap unSI SI+ instance Show (StatePlusT SI Identity P) where     show m = "StatePlus: " ++ show (runIdentity $ runStatePlusT m (SI [0]))