haccepted-0.1.0.0: Data structures and algorithms
Safe HaskellNone
LanguageHaskell2010

Array

Description

Arrays

Stuff to make it easier to work with arrays from the array package, especially when it comes to unboxed arrays. If the vector package is available, just use that.

Synopsis

Documentation

class Unbox a where Source #

Minimal complete definition

Nothing

Associated Types

type Unboxed a Source #

Methods

toU :: a -> Unboxed a Source #

default toU :: Coercible a (Unboxed a) => a -> Unboxed a Source #

frU :: Unboxed a -> a Source #

default frU :: Coercible (Unboxed a) a => Unboxed a -> a Source #

Instances

Instances details
Unbox MInt Source # 
Instance details

Defined in MInt

Associated Types

type Unboxed MInt Source #

Unbox (Min a) Source # 
Instance details

Defined in Array

Associated Types

type Unboxed (Min a) Source #

Methods

toU :: Min a -> Unboxed (Min a) Source #

frU :: Unboxed (Min a) -> Min a Source #

Unbox (Max a) Source # 
Instance details

Defined in Array

Associated Types

type Unboxed (Max a) Source #

Methods

toU :: Max a -> Unboxed (Max a) Source #

frU :: Unboxed (Max a) -> Max a Source #

Unbox (Sum a) Source # 
Instance details

Defined in Array

Associated Types

type Unboxed (Sum a) Source #

Methods

toU :: Sum a -> Unboxed (Sum a) Source #

frU :: Unboxed (Sum a) -> Sum a Source #

Unbox (Mod m i) Source # 
Instance details

Defined in Mod

Associated Types

type Unboxed (Mod m i) Source #

Methods

toU :: Mod m i -> Unboxed (Mod m i) Source #

frU :: Unboxed (Mod m i) -> Mod m i Source #

data Arr arr i a Source #

Array type for element types isomorphic to other element types with existing array support. Primarily intended as a way to get unboxed arrays. As an example, if you have "newtype N = N Int", define "instance Unbox N where type Unboxed N = Int" and use UArr i N as an unboxed array for N. This is a lot more performant than a boxed Array i N. Also works with mutable arrays, IOUArr and STUArr.

Instances

Instances details
(Unbox a, IArray arr (Unboxed a)) => IArray (Arr arr) a Source # 
Instance details

Defined in Array

Methods

bounds :: Ix i => Arr arr i a -> (i, i) #

numElements :: Ix i => Arr arr i a -> Int

unsafeArray :: Ix i => (i, i) -> [(Int, a)] -> Arr arr i a

unsafeAt :: Ix i => Arr arr i a -> Int -> a

unsafeReplace :: Ix i => Arr arr i a -> [(Int, a)] -> Arr arr i a

unsafeAccum :: Ix i => (a -> e' -> a) -> Arr arr i a -> [(Int, e')] -> Arr arr i a

unsafeAccumArray :: Ix i => (a -> e' -> a) -> a -> (i, i) -> [(Int, e')] -> Arr arr i a

(Unbox a, Monad m, MArray marr (Unboxed a) m) => MArray (Arr marr) a m Source # 
Instance details

Defined in Array

Methods

getBounds :: Ix i => Arr marr i a -> m (i, i) #

getNumElements :: Ix i => Arr marr i a -> m Int

newArray :: Ix i => (i, i) -> a -> m (Arr marr i a) #

newArray_ :: Ix i => (i, i) -> m (Arr marr i a) #

unsafeNewArray_ :: Ix i => (i, i) -> m (Arr marr i a)

unsafeRead :: Ix i => Arr marr i a -> Int -> m a

unsafeWrite :: Ix i => Arr marr i a -> Int -> a -> m ()

(IArray (Arr arr) a, Ix i, Show i, Show a) => Show (Arr arr i a) Source # 
Instance details

Defined in Array

Methods

showsPrec :: Int -> Arr arr i a -> ShowS #

show :: Arr arr i a -> String #

showList :: [Arr arr i a] -> ShowS #

NFData (arr i (Unboxed a)) => NFData (Arr arr i a) Source # 
Instance details

Defined in Array

Methods

rnf :: Arr arr i a -> () #

type STUArr s = Arr (STUArray s) Source #

data Arr2 arra arrb i ab Source #

Arrays for 2-tuples Primarily intended as a way to get unboxed arrays. If a and b can be put in UArrays, UArr2 i (a,b) works as an unboxed array for (a,b). This is a lot more performant than a boxed Array i (a,b). Also works with mutable arrays, STUArr2 and IOUArr2. Can be nested to get UArr3, UArr4, etc. Use with Unbox and Arr to store your own types.

Instances

Instances details
(IArray arra a, IArray arrb b) => IArray (Arr2 arra arrb) (a, b) Source # 
Instance details

Defined in Array

Methods

bounds :: Ix i => Arr2 arra arrb i (a, b) -> (i, i) #

numElements :: Ix i => Arr2 arra arrb i (a, b) -> Int

unsafeArray :: Ix i => (i, i) -> [(Int, (a, b))] -> Arr2 arra arrb i (a, b)

unsafeAt :: Ix i => Arr2 arra arrb i (a, b) -> Int -> (a, b)

unsafeReplace :: Ix i => Arr2 arra arrb i (a, b) -> [(Int, (a, b))] -> Arr2 arra arrb i (a, b)

unsafeAccum :: Ix i => ((a, b) -> e' -> (a, b)) -> Arr2 arra arrb i (a, b) -> [(Int, e')] -> Arr2 arra arrb i (a, b)

unsafeAccumArray :: Ix i => ((a, b) -> e' -> (a, b)) -> (a, b) -> (i, i) -> [(Int, e')] -> Arr2 arra arrb i (a, b)

(Monad m, MArray marra a m, MArray marrb b m) => MArray (Arr2 marra marrb) (a, b) m Source # 
Instance details

Defined in Array

Methods

getBounds :: Ix i => Arr2 marra marrb i (a, b) -> m (i, i) #

getNumElements :: Ix i => Arr2 marra marrb i (a, b) -> m Int

newArray :: Ix i => (i, i) -> (a, b) -> m (Arr2 marra marrb i (a, b)) #

newArray_ :: Ix i => (i, i) -> m (Arr2 marra marrb i (a, b)) #

unsafeNewArray_ :: Ix i => (i, i) -> m (Arr2 marra marrb i (a, b))

unsafeRead :: Ix i => Arr2 marra marrb i (a, b) -> Int -> m (a, b)

unsafeWrite :: Ix i => Arr2 marra marrb i (a, b) -> Int -> (a, b) -> m ()

(IArray (Arr2 arra arrb) ab, Ix i, Show i, Show ab) => Show (Arr2 arra arrb i ab) Source # 
Instance details

Defined in Array

Methods

showsPrec :: Int -> Arr2 arra arrb i ab -> ShowS #

show :: Arr2 arra arrb i ab -> String #

showList :: [Arr2 arra arrb i ab] -> ShowS #

(NFData (arra i a), NFData (arrb i b)) => NFData (Arr2 arra arrb i (a, b)) Source # 
Instance details

Defined in Array

Methods

rnf :: Arr2 arra arrb i (a, b) -> () #

type STUArr3 s = Arr2 (STUArray s) (STUArr2 s) Source #

type STUArr4 s = Arr2 (STUArr2 s) (STUArr2 s) Source #