repa-flow-4.0.0.2: Data-parallel data flows.

Safe HaskellNone
LanguageHaskell98

Data.Repa.Flow.States

Synopsis

Documentation

class (Ord i, Eq i) => Next i where Source

Methods

first :: i Source

Get the zero for this index type.

next :: i -> i -> Maybe i Source

Given an index an arity, get the next index after this one, or Nothing if there aren't any more.

check :: i -> i -> Bool Source

Check if an index is valid for this arity.

Instances

Next Int

Integer indices.

Next ()

Unit indices.

Next (Int, Int)

Tuple indices.

class (Ord i, Next i, Monad m) => States i m where Source

Associated Types

data Refs i m a Source

A collection of mutable references.

Methods

extentRefs :: Refs i m a -> i Source

Get the extent of the collection.

newRefs :: i -> a -> m (Refs i m a) Source

Allocate a new state of the given arity, also returning an index to the first element of the collection.

readRefs :: Refs i m a -> i -> m a Source

Write an element of the state.

writeRefs :: Refs i m a -> i -> a -> m () Source

Read an element of the state.

Instances

States Int IO 
States Int m => States () m 

foldRefsM :: States i m => (a -> b -> b) -> b -> Refs i m a -> m b Source

Fold all the elements in a collection of refs.

toListM :: States i m => Refs i m a -> m [a] Source