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

Safe Haskell | Safe-Inferred
Language | Haskell98

Test.IOSpec.IORef

Contents

- The `IORefS` spec
- Manipulation and creation of IORefs

Description

A pure specification of mutable variables.

Synopsis

- data IORefS a
- data IORef a
- newIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => a -> IOSpec f (IORef a)
- readIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> IOSpec f a
- writeIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> a -> IOSpec f ()
- modifyIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> (a -> a) -> IOSpec f ()

# The `IORefS` spec

data IORefS a Source #

An expression of type `IOSpec IORefS a` corresponds to an `IO` computation that uses mutable references and returns a value of type `a`.

#### Instances

Instances details

Executable IORefS Source # | The `Executable` instance for the `IORefS` monad.
Instance details Defined in Test.IOSpec.IORef Methods step :: IORefS a -> VM (Step a) Source #
Functor IORefS Source # |
Instance details Defined in Test.IOSpec.IORef Methods fmap :: (a -> b) -> IORefS a -> IORefS b Source # (<$) :: a -> IORefS b -> IORefS a Source #

# Manipulation and creation of IORefs

data IORef a Source #

A mutable variable storing a value of type a. Note that the types stored by an `IORef` are assumed to be `Typeable`.

newIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => a -> IOSpec f (IORef a) Source #

The `newIORef` function creates a new mutable variable.

readIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> IOSpec f a Source #

The `readIORef` function reads the value stored in a mutable variable.

writeIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> a -> IOSpec f () Source #

The `writeIORef` function overwrites the value stored in a mutable variable.

modifyIORef :: forall a (f :: Type -> Type). (Typeable a, IORefS :<: f) => IORef a -> (a -> a) -> IOSpec f () Source #

The `modifyIORef` function applies a function to the value stored in and `IORef`.