IOSpec-0.3.1.2: A pure specification of the IO monad.

Safe Haskell | Safe-Inferred
Language | Haskell98

Test.IOSpec.MVar

Contents

- The `MVarS` spec
- Supported functions

Description

A pure specification of basic operations on MVars.

Synopsis

- data MVarS a
- data MVar a
- newEmptyMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => IOSpec f (MVar a)
- takeMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => MVar a -> IOSpec f a
- putMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => MVar a -> a -> IOSpec f ()

# The `MVarS` spec

data MVarS a Source #

An expression of type `IOSpec MVarS a` corresponds to an `IO` computation that uses shared, mutable variables and returns a value of type `a`.

By itself, `MVarS` is not terribly useful. You will probably want to use `IOSpec (ForkS :+: MVarS)`.

#### Instances

Instances details

Executable MVarS Source # |
Instance details Defined in Test.IOSpec.MVar Methods step :: MVarS a -> VM (Step a) Source #
Functor MVarS Source # |
Instance details Defined in Test.IOSpec.MVar Methods fmap :: (a -> b) -> MVarS a -> MVarS b Source # (<$) :: a -> MVarS b -> MVarS a Source #

# Supported functions

data MVar a Source #

An `MVar` is a shared, mutable variable.

newEmptyMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => IOSpec f (MVar a) Source #

The `newEmptyMVar` function creates a new `MVar` that is initially empty.

takeMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => MVar a -> IOSpec f a Source #

The `takeMVar` function removes the value stored in an `MVar`. If the `MVar` is empty, the thread is blocked.

putMVar :: forall a (f :: Type -> Type). (Typeable a, MVarS :<: f) => MVar a -> a -> IOSpec f () Source #

The `putMVar` function fills an `MVar` with a new value. If the `MVar` is not empty, the thread is blocked.