IOSpec 0.2.5 → 0.2.6
raw patch · 4 files changed
+26/−10 lines, 4 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Test.IOSpec.Fork: instance [overlap ok] Executable ForkS
- Test.IOSpec.Fork: instance [overlap ok] Functor ForkS
- Test.IOSpec.IORef: instance [overlap ok] Executable IORefS
- Test.IOSpec.IORef: instance [overlap ok] Functor IORefS
- Test.IOSpec.MVar: instance [overlap ok] Executable MVarS
- Test.IOSpec.MVar: instance [overlap ok] Functor MVarS
- Test.IOSpec.MVar: instance [overlap ok] Typeable1 MVar
- Test.IOSpec.STM: instance [overlap ok] Executable STMS
- Test.IOSpec.STM: instance [overlap ok] Functor STM
- Test.IOSpec.STM: instance [overlap ok] Functor STMS
- Test.IOSpec.STM: instance [overlap ok] Monad STM
- Test.IOSpec.Teletype: instance [overlap ok] Executable Teletype
- Test.IOSpec.Teletype: instance [overlap ok] Functor Teletype
- Test.IOSpec.Types: class (Functor sub, Functor sup) => :<: sub sup
- Test.IOSpec.Types: instance [overlap ok] (Functor f, Functor g) => Functor (f :+: g)
- Test.IOSpec.Types: instance [overlap ok] (Functor f, Functor g) => f :<: (f :+: g)
- Test.IOSpec.Types: instance [overlap ok] (f :<: g, Functor f, Functor g, Functor h) => f :<: (h :+: g)
- Test.IOSpec.Types: instance [overlap ok] Functor f => Functor (IOSpec f)
- Test.IOSpec.Types: instance [overlap ok] Functor f => Monad (IOSpec f)
- Test.IOSpec.Types: instance [overlap ok] Functor f => f :<: f
- Test.IOSpec.VirtualMachine: instance [overlap ok] (Executable f, Executable g) => Executable (f :+: g)
- Test.IOSpec.VirtualMachine: instance [overlap ok] Arbitrary Scheduler
- Test.IOSpec.VirtualMachine: instance [overlap ok] Arbitrary ThreadId
- Test.IOSpec.VirtualMachine: instance [overlap ok] CoArbitrary ThreadId
- Test.IOSpec.VirtualMachine: instance [overlap ok] Eq ThreadId
- Test.IOSpec.VirtualMachine: instance [overlap ok] Eq a => Eq (Effect a)
- Test.IOSpec.VirtualMachine: instance [overlap ok] Functor Effect
- Test.IOSpec.VirtualMachine: instance [overlap ok] Monad Effect
- Test.IOSpec.VirtualMachine: instance [overlap ok] Show Scheduler
- Test.IOSpec.VirtualMachine: instance [overlap ok] Show ThreadId
+ Test.IOSpec.Fork: instance GHC.Base.Functor Test.IOSpec.Fork.ForkS
+ Test.IOSpec.Fork: instance Test.IOSpec.VirtualMachine.Executable Test.IOSpec.Fork.ForkS
+ Test.IOSpec.IORef: instance GHC.Base.Functor Test.IOSpec.IORef.IORefS
+ Test.IOSpec.IORef: instance Test.IOSpec.VirtualMachine.Executable Test.IOSpec.IORef.IORefS
+ Test.IOSpec.MVar: instance GHC.Base.Functor Test.IOSpec.MVar.MVarS
+ Test.IOSpec.MVar: instance Test.IOSpec.VirtualMachine.Executable Test.IOSpec.MVar.MVarS
+ Test.IOSpec.STM: instance GHC.Base.Applicative Test.IOSpec.STM.STM
+ Test.IOSpec.STM: instance GHC.Base.Functor Test.IOSpec.STM.STM
+ Test.IOSpec.STM: instance GHC.Base.Functor Test.IOSpec.STM.STMS
+ Test.IOSpec.STM: instance GHC.Base.Monad Test.IOSpec.STM.STM
+ Test.IOSpec.STM: instance Test.IOSpec.VirtualMachine.Executable Test.IOSpec.STM.STMS
+ Test.IOSpec.Teletype: instance GHC.Base.Functor Test.IOSpec.Teletype.Teletype
+ Test.IOSpec.Teletype: instance Test.IOSpec.VirtualMachine.Executable Test.IOSpec.Teletype.Teletype
+ Test.IOSpec.Types: class (Functor sub, Functor sup) => (:<:) sub sup
+ Test.IOSpec.Types: instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (f Test.IOSpec.Types.:+: g)
+ Test.IOSpec.Types: instance (GHC.Base.Functor f, GHC.Base.Functor g) => f Test.IOSpec.Types.:<: (f Test.IOSpec.Types.:+: g)
+ Test.IOSpec.Types: instance (f Test.IOSpec.Types.:<: g, GHC.Base.Functor f, GHC.Base.Functor g, GHC.Base.Functor h) => f Test.IOSpec.Types.:<: (h Test.IOSpec.Types.:+: g)
+ Test.IOSpec.Types: instance GHC.Base.Functor f => GHC.Base.Applicative (Test.IOSpec.Types.IOSpec f)
+ Test.IOSpec.Types: instance GHC.Base.Functor f => GHC.Base.Functor (Test.IOSpec.Types.IOSpec f)
+ Test.IOSpec.Types: instance GHC.Base.Functor f => GHC.Base.Monad (Test.IOSpec.Types.IOSpec f)
+ Test.IOSpec.Types: instance GHC.Base.Functor f => f Test.IOSpec.Types.:<: f
+ Test.IOSpec.VirtualMachine: instance (Test.IOSpec.VirtualMachine.Executable f, Test.IOSpec.VirtualMachine.Executable g) => Test.IOSpec.VirtualMachine.Executable (f Test.IOSpec.Types.:+: g)
+ Test.IOSpec.VirtualMachine: instance GHC.Base.Applicative Test.IOSpec.VirtualMachine.Effect
+ Test.IOSpec.VirtualMachine: instance GHC.Base.Functor Test.IOSpec.VirtualMachine.Effect
+ Test.IOSpec.VirtualMachine: instance GHC.Base.Monad Test.IOSpec.VirtualMachine.Effect
+ Test.IOSpec.VirtualMachine: instance GHC.Classes.Eq Test.IOSpec.VirtualMachine.ThreadId
+ Test.IOSpec.VirtualMachine: instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.IOSpec.VirtualMachine.Effect a)
+ Test.IOSpec.VirtualMachine: instance GHC.Show.Show Test.IOSpec.VirtualMachine.Scheduler
+ Test.IOSpec.VirtualMachine: instance GHC.Show.Show Test.IOSpec.VirtualMachine.ThreadId
+ Test.IOSpec.VirtualMachine: instance Test.QuickCheck.Arbitrary.Arbitrary Test.IOSpec.VirtualMachine.Scheduler
+ Test.IOSpec.VirtualMachine: instance Test.QuickCheck.Arbitrary.Arbitrary Test.IOSpec.VirtualMachine.ThreadId
+ Test.IOSpec.VirtualMachine: instance Test.QuickCheck.Arbitrary.CoArbitrary Test.IOSpec.VirtualMachine.ThreadId
- Test.IOSpec.STM: atomically :: STMS :<: f => STM a -> IOSpec f a
+ Test.IOSpec.STM: atomically :: (STMS :<: f) => STM a -> IOSpec f a
- Test.IOSpec.Teletype: getChar :: :<: Teletype f => IOSpec f Char
+ Test.IOSpec.Teletype: getChar :: (:<:) Teletype f => IOSpec f Char
- Test.IOSpec.Teletype: getLine :: Teletype :<: f => IOSpec f String
+ Test.IOSpec.Teletype: getLine :: (Teletype :<: f) => IOSpec f String
- Test.IOSpec.Teletype: putChar :: Teletype :<: f => Char -> IOSpec f ()
+ Test.IOSpec.Teletype: putChar :: (Teletype :<: f) => Char -> IOSpec f ()
- Test.IOSpec.Teletype: putStr :: Teletype :<: f => String -> IOSpec f ()
+ Test.IOSpec.Teletype: putStr :: (Teletype :<: f) => String -> IOSpec f ()
- Test.IOSpec.Teletype: putStrLn :: Teletype :<: f => String -> IOSpec f ()
+ Test.IOSpec.Teletype: putStrLn :: (Teletype :<: f) => String -> IOSpec f ()
- Test.IOSpec.Types: Inl :: (f x) -> :+: f g x
+ Test.IOSpec.Types: Inl :: (f x) -> (:+:) f g x
- Test.IOSpec.Types: Inr :: (g x) -> :+: f g x
+ Test.IOSpec.Types: Inr :: (g x) -> (:+:) f g x
- Test.IOSpec.Types: inject :: g :<: f => g (IOSpec f a) -> IOSpec f a
+ Test.IOSpec.Types: inject :: (g :<: f) => g (IOSpec f a) -> IOSpec f a
Files
- IOSpec.cabal +3/−3
- src/Test/IOSpec/STM.hs +12/−7
- src/Test/IOSpec/Types.hs +6/−0
- src/Test/IOSpec/VirtualMachine.hs +5/−0
IOSpec.cabal view
@@ -1,8 +1,8 @@ Name: IOSpec-Version: 0.2.5+Version: 0.2.6 License: BSD3 License-file: LICENSE-Author: Wouter Swierstra, Yusaku Hashimoto+Author: Wouter Swierstra, Yusaku Hashimoto, Nikolay Amiantov Maintainer: Wouter Swierstra <wouter.swierstra@gmail.com> Synopsis: A pure specification of the IO monad. Description: This package consists of several modules, that give a@@ -41,7 +41,7 @@ with the source distribution. Category: Testing Build-Type: Simple-Build-Depends: base >= 2 && < 5, mtl, QuickCheck >= 2 && < 3, Stream+Build-Depends: base >= 4.8.0.0 && < 5, mtl, QuickCheck >= 2 && < 3, Stream Extensions: MultiParamTypeClasses, OverlappingInstances Ghc-options: -Wall Hs-source-dirs: src
src/Test/IOSpec/STM.hs view
@@ -23,6 +23,7 @@ import Data.Dynamic import Data.Maybe (fromJust) import Control.Monad.State+import Control.Monad (ap) -- The 'STMS' data type and its instances. --@@ -67,14 +68,18 @@ fmap _ Retry = Retry fmap f (OrElse io1 io2) = OrElse (fmap f io1) (fmap f io2) +instance Applicative STM where+ pure = STMReturn+ (<*>) = ap+ instance Monad STM where- return = STMReturn- STMReturn a >>= f = f a- NewTVar d g >>= f = NewTVar d (\l -> g l >>= f)- ReadTVar l g >>= f = ReadTVar l (\d -> g d >>= f)- WriteTVar l d p >>= f = WriteTVar l d (p >>= f)- Retry >>= _ = Retry- OrElse p q >>= f = OrElse (p >>= f) (q >>= f)+ return = STMReturn+ STMReturn a >>= f = f a+ NewTVar d g >>= f = NewTVar d (\l -> g l >>= f)+ ReadTVar l g >>= f = ReadTVar l (\d -> g d >>= f)+ WriteTVar l d p >>= f = WriteTVar l d (p >>= f)+ Retry >>= _ = Retry+ OrElse p q >>= f = OrElse (p >>= f) (q >>= f) -- | A 'TVar' is a shared, mutable variable used by STM. newtype TVar a = TVar Loc
src/Test/IOSpec/Types.hs view
@@ -15,6 +15,8 @@ , inject ) where +import Control.Monad (ap)+ -- | A value of type 'IOSpec' @f@ @a@ is either a pure value of type @a@ -- or some effect, determined by @f@. Crucially, 'IOSpec' @f@ is a -- monad, provided @f@ is a functor.@@ -25,6 +27,10 @@ instance (Functor f) => Functor (IOSpec f) where fmap f (Pure x) = Pure (f x) fmap f (Impure t) = Impure (fmap (fmap f) t)++instance (Functor f) => Applicative (IOSpec f) where+ pure = Pure+ (<*>) = ap instance (Functor f) => Monad (IOSpec f) where return = Pure
src/Test/IOSpec/VirtualMachine.hs view
@@ -43,6 +43,7 @@ import qualified Data.Stream as Stream import Test.IOSpec.Types import Test.QuickCheck+import Control.Monad (ap) type Data = Dynamic type Loc = Int@@ -210,6 +211,10 @@ fmap f (ReadChar t) = ReadChar (\c -> fmap f (t c)) fmap f (Print c t) = Print c (fmap f t) fmap _ (Fail msg) = Fail msg++instance Applicative Effect where+ pure = Done+ (<*>) = ap instance Monad Effect where return = Done