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

Test.IOSpec.IORef

Contents

Description

A pure specification of mutable variables.

Synopsis

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

Functor IORefS 
Executable IORefS

The Executable instance for the IORefS monad.

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 :: (Typeable a, IORefS :<: f) => a -> IOSpec f (IORef a)Source

The newIORef function creates a new mutable variable.

readIORef :: (Typeable a, IORefS :<: f) => IORef a -> IOSpec f aSource

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

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

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

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

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