linear-base-0.4.0: Standard library for linear types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Array.Polarized.Pull

Description

This module provides pull arrays.

These are part of a larger framework for controlling when memory is allocated for an array. See Data.Array.Polarized.

Synopsis

Documentation

data Array a Source #

A pull array is an array from which it is easy to extract elements, and this can be done in any order. The linear consumption of a pull array means each element is consumed exactly once, but the length can be accessed freely.

Instances

Instances details
Functor Array Source # 
Instance details

Defined in Data.Array.Polarized.Pull.Internal

Methods

fmap :: (a %1 -> b) -> Array a %1 -> Array b Source #

Semigroup (Array a) Source # 
Instance details

Defined in Data.Array.Polarized.Pull.Internal

Methods

(<>) :: Array a -> Array a -> Array a #

sconcat :: NonEmpty (Array a) -> Array a #

stimes :: Integral b => b -> Array a -> Array a #

Semigroup (Array a) Source # 
Instance details

Defined in Data.Array.Polarized.Pull.Internal

Methods

(<>) :: Array a %1 -> Array a %1 -> Array a Source #

Construction

fromFunction :: (Int -> a) -> Int -> Array a Source #

fromFunction arrIndexer len constructs a pull array given a function arrIndexer that goes from an array index to array values and a specified length len.

fromVector :: Vector a %1 -> Array a Source #

Convert a Vector to a pull array.

make :: a -> Int -> Array a Source #

Creates a pull array of given size, filled with the given element.

singleton :: a %1 -> Array a Source #

Produce a pull array of lenght 1 consisting of solely the given element.

Consumption

toVector :: Array a %1 -> Vector a Source #

This is a convenience function for alloc . transfer

asList :: Array a %1 -> [a] Source #

Convert a pull array into a list.

Operations

zip :: Array a %1 -> Array b %1 -> Array (a, b) Source #

zip [x1, ..., xn] [y1, ..., yn] = [(x1,y1), ..., (xn,yn)] Partial: `zip [x1,x2,...,xn] [y1,y2,...,yp]` is an error if n ≠ p.

zipWith :: (a %1 -> b %1 -> c) -> Array a %1 -> Array b %1 -> Array c Source #

zipWith f [x1,x2,...,xn] [y1,y2,...,yn] = [f x1 y1, ..., f xn yn] Partial: `zipWith f [x1,x2,...,xn] [y1,y2,...,yp]` is an error if n ≠ p.

append :: Array a %1 -> Array a %1 -> Array a Source #

Concatenate two pull arrays.

foldr :: (a %1 -> b %1 -> b) -> b %1 -> Array a %1 -> b Source #

A right-fold of a pull array.

foldMap :: Monoid m => (a %1 -> m) -> Array a %1 -> m Source #

Fold a pull array using a monoid.

findLength :: Array a %1 -> (Int, Array a) Source #

Extract the length of an array, and give back the original array.

split :: Int -> Array a %1 -> (Array a, Array a) Source #

split n v = (vl, vr) such that vl has length n.

split is total: if n is larger than the length of v, then vr is empty.

reverse :: Array a %1 -> Array a Source #

Reverse a pull array.

index :: Array a %1 -> Int -> (a, Array a) Source #

Index a pull array (without checking bounds)