loops-0.2.0.2: Fast imperative-style loops

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Loop.ForEach

Synopsis

Documentation

class ForEach m c where Source

Class of containers that can be iterated over. The class is parameterized over a base monad where the values of the container can be read to allow iterating over mutable structures. The associated type families parameterize the value and index types of the container, allowing the class to be instantiated for container types (unboxed or storable vectors, for example) which do not admit all types as values.

Associated Types

type ForEachValue c Source

type ForEachIx c Source

Methods

forEach :: Unrolling (UnTL n) => Unroll n -> c -> m (ForEachValue c) Source

Iterate over the values in the container.

iforEach :: Unrolling (UnTL n) => Unroll n -> c -> m (ForEachIx c, ForEachValue c) Source

Iterate over the indices and the value at each index.

Instances

(Monad m, Storable a) => ForEach (LoopT * m) (Vector a) 
(Monad m, Prim a) => ForEach (LoopT * m) (Vector a) 
(Monad m, Unbox a) => ForEach (LoopT * m) (Vector a) 
Monad m => ForEach (LoopT * m) (Vector a) 
Monad m => ForEach (LoopT * m) [a] 
(Storable a, PrimMonad m, (~) * (PrimState m) s) => ForEach (LoopT * m) (MVector s a) 
(PrimMonad m, Prim a, (~) * (PrimState m) s) => ForEach (LoopT * m) (MVector s a) 
(PrimMonad m, Unbox a, (~) * (PrimState m) s) => ForEach (LoopT * m) (MVector s a) 
(PrimMonad m, (~) * (PrimState m) s) => ForEach (LoopT * m) (MVector s a) 

forEachVector :: (Monad m, Vector v a, Unrolling (UnTL n)) => Unroll n -> v a -> LoopT m a Source

iforEachVector :: (Monad m, Vector v a, Unrolling (UnTL n)) => Unroll n -> v a -> LoopT m (Int, a) Source

forEachMVector :: (PrimMonad m, MVector v a, Unrolling (UnTL n)) => Unroll n -> v (PrimState m) a -> LoopT m a Source

iforEachMVector :: (PrimMonad m, MVector v a, Unrolling (UnTL n)) => Unroll n -> v (PrimState m) a -> LoopT m (Int, a) Source