-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A pure specification of the IO monad. -- -- At the moment this package consists of four modules: -- -- -- -- There are several well-documented examples included with the source -- distribution. @package IOSpec @version 0.1 -- | A pure specification of mutable variables. module Test.IOSpec.IORef -- | The IOState monad data IOState a -- | The runIOState function executes a computation in the -- IOState monad. runIOState :: IOState a -> a -- | A mutable variable in the IOState monad data IORef a -- | The newIORef function creates a new mutable variable. newIORef :: (Typeable a) => a -> IOState (IORef a) -- | The readIORef function reads the value stored in a mutable -- variable. readIORef :: (Typeable a) => IORef a -> IOState a -- | The writeIORef function overwrites the value stored in an -- IORef. writeIORef :: (Typeable a) => IORef a -> a -> IOState () -- | The modifyIORef function applies a function to the value stored -- in and IORef. modifyIORef :: (Typeable a) => IORef a -> (a -> a) -> IOState () instance Monad IOState instance Functor IOState -- | Streams are infinite lists. Most operations on streams are completely -- analogous to the definition in Data.List. module Data.Stream data Stream a Cons :: a -> (Stream a) -> Stream a head :: Stream a -> a tail :: Stream a -> Stream a intersperse :: a -> Stream a -> Stream a iterate :: (a -> a) -> a -> Stream a repeat :: a -> Stream a cycle :: [a] -> Stream a unfold :: (c -> (a, c)) -> c -> Stream a take :: Int -> Stream a -> [a] drop :: (Num a, Ord a) => a -> Stream a1 -> Stream a1 splitAt :: Int -> Stream a -> ([a], Stream a) takeWhile :: (a -> Bool) -> Stream a -> [a] dropWhile :: (a -> Bool) -> Stream a -> Stream a span :: (a -> Bool) -> Stream a -> ([a], Stream a) break :: (a -> Bool) -> Stream a -> ([a], Stream a) isPrefixOf :: (Eq a) => [a] -> Stream a -> Bool filter :: (a -> Bool) -> Stream a -> Stream a partition :: (a -> Bool) -> Stream a -> (Stream a, Stream a) (!!) :: Int -> Stream a -> a zip :: Stream a -> Stream b -> Stream (a, b) zipWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c unzip :: Stream (a, b) -> (Stream a, Stream b) words :: Stream Char -> Stream String unwords :: Stream String -> Stream Char lines :: Stream Char -> Stream String unlines :: Stream String -> Stream Char listToStream :: [t] -> Stream [t] streamToList :: Stream a -> [a] instance (Show a) => Show (Stream a) instance (Eq a) => Eq (Stream a) instance (Arbitrary a) => Arbitrary (Stream a) instance Applicative Stream instance Functor Stream -- | A pure specification of basic concurrency operations. module Test.IOSpec.Concurrent data IOConc a -- | The runIOConc function runs a concurrent computation with a -- given scheduler. If a deadlock occurs, Nothing is returned. runIOConc :: IOConc a -> Scheduler -> Maybe a data ThreadId -- | An MVar is a shared, mutable variable. data MVar a -- | The newEmptyMVar function creates a new MVar that is -- initially empty. newEmptyMVar :: IOConc (MVar a) -- | The takeMVar function removes the value stored in an -- MVar. If the MVar is empty, the thread is blocked. takeMVar :: (Typeable a) => MVar a -> IOConc a -- | The putMVar function fills an MVar with a new value. If -- the MVar is not empty, the thread is blocked. putMVar :: (Typeable a) => MVar a -> a -> IOConc () -- | The forkIO function forks off a new thread. forkIO :: IOConc a -> IOConc ThreadId -- | A scheduler consists of a function that, given the number of threads, -- returns the ThreadId of the next scheduled thread, together -- with a new scheduler. newtype Scheduler Scheduler :: (Int -> (ThreadId, Scheduler)) -> Scheduler -- | Given a stream of integers, streamSched builds a scheduler. -- This is especially useful if you use QuickCheck and generate a random -- stream; the resulting random scheduler will hopefully cover a large -- number of interleavings. streamSched :: Stream Int -> Scheduler -- | A simple round-robin scheduler. roundRobin :: Scheduler instance Typeable1 MVar instance Eq ThreadId instance Show ThreadId instance Monad IOConc instance Functor IOConc -- | A pure implementation of getChar and putChar. module Test.IOSpec.Teletype -- | The IOTeletype monad data IOTeletype a -- | The result of running a teletype interation is a (potentially -- infinite) list of characters, that are printed to the screen. The -- interaction can also end, and return a final value, using the -- Finish constructor. data Output a Print :: Char -> (Output a) -> Output a Finish :: a -> Output a -- | Once you have constructed something of type IOTeletype you can -- run the interaction. If you pass in a stream of characters entered at -- the teletype, it will produce a value of type Output runTT :: IOTeletype a -> Stream Char -> Output a -- | The getChar function can be used to read input from the teletype. getChar :: IOTeletype Char -- | The getChar function can be used to print to the teletype. putChar :: Char -> IOTeletype () instance Monad IOTeletype instance Functor IOTeletype module Test.IOSpec