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

Safe HaskellNone
LanguageHaskell98

Data.Repa.Flow.States

Synopsis

Documentation

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

Minimal complete definition

first, next, check

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 Source #

Integer indices.

Methods

first :: Int Source #

next :: Int -> Int -> Maybe Int Source #

check :: Int -> Int -> Bool Source #

Next () Source #

Unit indices.

Methods

first :: () Source #

next :: () -> () -> Maybe () Source #

check :: () -> () -> Bool Source #

Next (Int, Int) Source #

Tuple indices.

Methods

first :: (Int, Int) Source #

next :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) Source #

check :: (Int, Int) -> (Int, Int) -> Bool Source #

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

Minimal complete definition

extentRefs, newRefs, readRefs, writeRefs

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 Source # 

Associated Types

data Refs Int (IO :: * -> *) a :: * Source #

Methods

extentRefs :: Refs Int IO a -> Int Source #

newRefs :: Int -> a -> IO (Refs Int IO a) Source #

readRefs :: Refs Int IO a -> Int -> IO a Source #

writeRefs :: Refs Int IO a -> Int -> a -> IO () Source #

(Monad m, States Int m) => States () m Source # 

Associated Types

data Refs () (m :: * -> *) a :: * Source #

Methods

extentRefs :: Refs () m a -> () Source #

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

readRefs :: Refs () m a -> () -> m a Source #

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

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 #