This is a module for creating and manipulating mutable generators. Generators contain a source finite list and a counter. Items are retrieved from the list one at a time, and the list loops when the last item has been given.
- newGenerator :: [a] -> IO (Generator a)
- swapGenerator :: Generator a -> [a] -> IO [a]
- newCounter :: IO (IORef Int)
- getCount :: Generator a -> IO Int
- getGeneratorSource :: Generator a -> IO [a]
- resetCounter :: Generator a -> IO ()
- next :: Generator a -> IO a
- nextWithOffset :: Int -> Generator a -> IO a
- nexts :: [Generator b] -> IO [b]
- withNext :: Generator a -> (a -> b) -> IO b
- newGeneratorStore :: Ord t => (t, [a]) -> IO (Map t (Generator a))
- defaultGeneratorStore :: IO (Map [Char] (Generator Double))
Documentation
newGenerator :: [a] -> IO (Generator a)Source
creates a new Generator from the given source list.
swapGenerator :: Generator a -> [a] -> IO [a]Source
swaps the source of a Generator
newCounter :: IO (IORef Int)Source
getGeneratorSource :: Generator a -> IO [a]Source
returns the source of a Generator
resetCounter :: Generator a -> IO ()Source
resets the counter of a Generator
nextWithOffset :: Int -> Generator a -> IO aSource
adds the first argument to the counter value of a Generator and returns the corresponding item from the source
nexts :: [Generator b] -> IO [b]Source
given a list of Generators, returns a list containing the next item from all of them
withNext :: Generator a -> (a -> b) -> IO bSource
runs a pure function on the next item from a Generator