fixed-vector-0.8.0.0: Generic vectors with statically known size.

Data.Vector.Fixed.Monomorphic

Description

Wrapper function for working with monomorphic vectors. Standard API require vector to be parametric in their element type making it impossible to work with vectors like

`data Vec3 = Vec3 Double Double Double`

This module provides newtype wrapper which allows use of functions from Data.Vector.Fixed with such data types and function which works with such vectors.

Functions have same meaning as ones from Data.Vector.Fixed and documented there.

Synopsis

# Vector type class

## Vector size

type family DimMono v :: * Source

Dimensions of monomorphic vector.

data Z Source

Type level zero

Instances

 Arity Z Typeable * Z NatIso Z 0 Arity n => Index Z (S n) type Add Z n = n type Fn Z a b = b

data S n Source

Successor of n

Instances

 Arity n => Index Z (S n) Arity n => Arity (S n) (NatIso k ((-) n 1), (~) * (ToPeano ((-) n 1)) k, (~) * (ToPeano n) (S k), (~) Nat n ((+) 1 ((-) n 1))) => NatIso (S k) n Index k n => Index (S k) (S n) Typeable (* -> *) S type Add (S n) k = S (Add n k) type Fn (S n) a b = a -> Fn n a b

## Synonyms for small numerals

type N1 = S Z Source

type N2 = S N1 Source

type N3 = S N2 Source

type N4 = S N3 Source

type N5 = S N4 Source

type N6 = S N5 Source

## Type class

class Arity (DimMono v) => VectorMono v where Source

Counterpart of `Vector` type class for monomorphic vectors.

Minimal complete definition

Associated Types

type VectorElm v :: * Source

Type of vector elements.

Methods

construct :: Fun (DimMono v) (VectorElm v) v Source

Construct vector

inspect :: v -> Fun (DimMono v) (VectorElm v) r -> r Source

Inspect vector

basicIndex :: v -> Int -> VectorElm v Source

Optional more efficient implementation of indexing

class Arity n Source

Type class for handling n-ary functions.

Minimal complete definition

Instances

 Arity Z Arity n => Arity (S n)

newtype Fun n a b Source

Newtype wrapper which is used to make `Fn` injective. It's also a reader monad.

Constructors

 Fun FieldsunFun :: Fn n a b

Instances

 Arity n => Monad (Fun n a) Arity n => Functor (Fun n a) Arity n => Applicative (Fun n a)

length :: Arity (DimMono v) => v -> Int Source

Length of vector

# Constructors

mk1 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ N1) => a -> v Source

mk2 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ N2) => a -> a -> v Source

mk3 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ N3) => a -> a -> a -> v Source

mk4 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ N4) => a -> a -> a -> a -> v Source

mk5 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ N5) => a -> a -> a -> a -> a -> v Source

## Functions

replicate :: (VectorMono v, VectorElm v ~ a) => a -> v Source

replicateM :: (VectorMono v, VectorElm v ~ a, Monad m) => m a -> m v Source

generate :: (VectorMono v, VectorElm v ~ a) => (Int -> a) -> v Source

generateM :: (Monad m, VectorMono v, VectorElm v ~ a) => (Int -> m a) -> m v Source

unfoldr :: (VectorMono v, VectorElm v ~ a) => (b -> (a, b)) -> b -> v Source

basis :: (VectorMono v, VectorElm v ~ a, Num a) => Int -> v Source

# Modifying vectors

## Transformations

head :: (VectorMono v, VectorElm v ~ a, DimMono v ~ S n) => v -> a Source

tail :: (VectorMono v, VectorElm v ~ a, VectorMono w, VectorElm w ~ a, DimMono v ~ S (DimMono w)) => v -> w Source

reverse :: VectorMono v => v -> v Source

(!) :: (VectorMono v, VectorElm v ~ a) => v -> Int -> a Source

## Comparison

eq :: (VectorMono v, VectorElm v ~ a, Eq a) => v -> v -> Bool Source

## Maps

map :: (VectorMono v, VectorElm v ~ a) => (a -> a) -> v -> v Source

mapM :: (VectorMono v, VectorElm v ~ a, Monad m) => (a -> m a) -> v -> m v Source

mapM_ :: (VectorMono v, VectorElm v ~ a, Monad m) => (a -> m b) -> v -> m () Source

imap :: (VectorMono v, VectorElm v ~ a) => (Int -> a -> a) -> v -> v Source

imapM :: (VectorMono v, VectorElm v ~ a, Monad m) => (Int -> a -> m a) -> v -> m v Source

imapM_ :: (VectorMono v, VectorElm v ~ a, Monad m) => (Int -> a -> m b) -> v -> m () Source

# Folding

foldl :: (VectorMono v, VectorElm v ~ a) => (b -> a -> b) -> b -> v -> b Source

foldr :: (VectorMono v, VectorElm v ~ a) => (a -> b -> b) -> b -> v -> b Source

foldl1 :: (VectorMono v, VectorElm v ~ a, DimMono v ~ S n) => (a -> a -> a) -> v -> a Source

ifoldl :: (VectorMono v, VectorElm v ~ a) => (b -> Int -> a -> b) -> b -> v -> b Source

ifoldr :: (VectorMono v, VectorElm v ~ a) => (Int -> a -> b -> b) -> b -> v -> b Source

foldMap :: (VectorMono v, Monoid m) => (VectorElm v -> m) -> v -> m Source

foldM :: (VectorMono v, VectorElm v ~ a, Monad m) => (b -> a -> m b) -> b -> v -> m b Source

ifoldM :: (VectorMono v, VectorElm v ~ a, Monad m) => (b -> Int -> a -> m b) -> b -> v -> m b Source

## Special folds

sum :: (VectorMono v, VectorElm v ~ a, Num a) => v -> a Source

maximum :: (VectorMono v, VectorElm v ~ a, DimMono v ~ S n, Ord a) => v -> a Source

minimum :: (VectorMono v, VectorElm v ~ a, DimMono v ~ S n, Ord a) => v -> a Source

and :: (VectorMono v, VectorElm v ~ Bool) => v -> Bool Source

or :: (VectorMono v, VectorElm v ~ Bool) => v -> Bool Source

all :: (VectorMono v, VectorElm v ~ a) => (a -> Bool) -> v -> Bool Source

any :: (VectorMono v, VectorElm v ~ a) => (a -> Bool) -> v -> Bool Source

# Zips

zipWith :: (VectorMono v, VectorElm v ~ a) => (a -> a -> a) -> v -> v -> v Source

zipWithM :: (VectorMono v, VectorElm v ~ a, Monad m) => (a -> a -> m a) -> v -> v -> m v Source

izipWith :: (VectorMono v, VectorElm v ~ a) => (Int -> a -> a -> a) -> v -> v -> v Source

izipWithM :: (VectorMono v, VectorElm v ~ a, Monad m) => (Int -> a -> a -> m a) -> v -> v -> m v Source

# Conversion

toList :: (VectorMono v, VectorElm v ~ a) => v -> [a] Source

fromList :: (VectorMono v, VectorElm v ~ a) => [a] -> v Source