primal-memory-0.3.0.0: Unified interface for memory managemenet.
Copyright(c) Alexey Kuleshevich 2020
LicenseBSD3
MaintainerAlexey Kuleshevich <alexey@kuleshevi.ch>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Prim.Memory.Fold

Description

 
Synopsis

Documentation

foldlMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (a -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldlMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (a -> Off e -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldlOffMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> Off e

Initial offset to start at

-> Count e

Total number of elements to iterate through

-> (a -> Off e -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

foldlLazyMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (a -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldlLazyMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (a -> Off e -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldlLazyOffMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> Off e

Initial offset to start at

-> Count e

Total number of elements to iterate through

-> (a -> Off e -> e -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

foldrMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldrMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (Off e -> e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

ifoldrOffMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> Off e

Initial offset to start at

-> Count e

Total number of elements to iterate through

-> (Off e -> e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

foldrLazyMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

Right fold with a lazy accumulator

Since: 0.3.0

ifoldrLazyMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> (Off e -> e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

Right fold with a lazy accumulator using an offset aware function

Since: 0.3.0

ifoldrLazyOffMem Source #

Arguments

:: forall e a mr. (Prim e, MemRead mr) 
=> Off e

Initial offset to start at

-> Count e

Total number of elements to iterate through

-> (Off e -> e -> a -> a)

Folding function

-> a

Initial accumulator

-> mr

Memory region to iterate over

-> a 

foldMapOffMem :: forall e m mr. (Prim e, MemRead mr, Monoid m) => Off e -> Count e -> (e -> m) -> mr -> m Source #

ifoldMapOffMem :: forall e m mr. (Prim e, MemRead mr, Monoid m) => Off e -> Count e -> (Off e -> e -> m) -> mr -> m Source #

anyOffMem :: forall e mr. (Prim e, MemRead mr) => Off e -> Count e -> (e -> Bool) -> mr -> Bool Source #

ianyOffMem :: forall e mr. (Prim e, MemRead mr) => Off e -> Count e -> (Off e -> e -> Bool) -> mr -> Bool Source #

anyMem :: forall e mr. (Prim e, MemRead mr) => (e -> Bool) -> mr -> Bool Source #

ianyMem :: forall e mr. (Prim e, MemRead mr) => (Off e -> e -> Bool) -> mr -> Bool Source #

allOffMem :: forall e mr. (Prim e, MemRead mr) => Off e -> Count e -> (e -> Bool) -> mr -> Bool Source #

iallOffMem :: forall e mr. (Prim e, MemRead mr) => Off e -> Count e -> (Off e -> e -> Bool) -> mr -> Bool Source #

allMem :: forall e mr. (Prim e, MemRead mr) => (e -> Bool) -> mr -> Bool Source #

iallMem :: forall e mr. (Prim e, MemRead mr) => (Off e -> e -> Bool) -> mr -> Bool Source #

eqMem :: forall e mr. (Prim e, Eq e, MemRead mr) => mr -> mr -> Bool Source #

eqOffMem Source #

Arguments

:: (Prim e, Eq e, MemRead mr1, MemRead mr2) 
=> mr1

memRead1 - First region of memory

-> Off e

memOff1 - Offset for memRead1 in number of elements

Precondition:

0 <= memOff1
-> mr2

memRead2 - Second region of memory

-> Off e

memOff2 - Offset for memRead1 in number of elements

Precondition:

0 <= memOff2
-> Count e

memCount - Number of elements of type e to compare

Preconditions:

0 <= memCount
offToCount memOff1 + memCount < countMem memRead1
offToCount memOff2 + memCount < countMem memRead2
-> Bool 

Check two regions of memory for equality using the Eq instance. It will return True whenever both regions hold exactly the same elements and False as soon as the first pair of mismatched elements is discovered in the two regions. It is safe for both regions to refer to the same part of memory.

Unsafe
When any precondition for either of the offsets memOff1, memOff2 or the element count memCount is violated the result is either unpredictable output or failure with a segfault.

Since: 0.3.0

eqOffMemBinary :: forall e mr1 mr2. (Prim e, MemRead mr1, MemRead mr2) => mr1 -> Off e -> mr2 -> Off e -> Count e -> Bool Source #

eqOffMutMem :: forall e ma1 ma2 m s. (Prim e, Eq e, MonadPrim s m, MemWrite ma1, MemWrite ma2) => ma1 s -> Off e -> ma2 s -> Off e -> Count e -> m Bool Source #

eqMutMem :: forall e ma m s. (Prim e, Eq e, MonadPrim s m, MemAlloc ma) => ma s -> ma s -> m Bool Source #

Compare two mutable memory regions for element equality. Regions themselves are not modified, as such it is semantically similar to eqMem which works on immutable regions.

compareMem Source #

Arguments

:: forall e mr. (Prim e, Ord e, MemRead mr) 
=> mr

memRead1 - First region of memory

-> mr

memRead2 - Second region of memory

-> Ordering 

Compare two regions using the Ord instance. It will return EQ whenever both regions hold exactly the same elements and LT or GT as soon as the first discovered element that is less than or greater than respectfully in the first region when compared to the second one. It is safe for both regions to refer to the same part of memory.

Since: 0.3.0

compareOffMem Source #

Arguments

:: (Prim e, Ord e, MemRead mr1, MemRead mr2) 
=> mr1

memRead1 - First region of memory

-> Off e

memOff1 - Offset for memRead1 in number of elements

Precondition:

0 <= memOff1
-> mr2

memRead2 - Second region of memory

-> Off e

memOff2 - Offset for memRead1 in number of elements

Precondition:

0 <= memOff2
-> Count e

memCount - Number of elements of type e to compare

Preconditions:

0 <= memCount
offToCount memOff1 + memCount < countMem memRead1
offToCount memOff2 + memCount < countMem memRead2
-> Ordering 

Compare two regions using the Ord instance. It will return EQ whenever both regions hold exactly the same elements and LT or GT as soon as the first discovered element that is less than or greater than respectfully in the first region when compared to the second one. It is safe for both regions to refer to the same part of memory.

Unsafe
When any precondition for either of the offsets memOff1, memOff2 or the element count memCount is violated the result is either unpredictable output or failure with a segfault.

Since: 0.3.0