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

Safe HaskellNone
LanguageHaskell98

Data.Vector.Fixed.Monomorphic

Contents

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 Source # 

Methods

accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t Z -> Fun Z a b Source #

applyFun :: (forall k. t (S k) -> (a, t k)) -> t Z -> Fn Z a b -> (b, t Z) Source #

applyFunM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t Z -> m (ContVec Z a, t Z) Source #

arity :: Z -> Int Source #

reverseF :: Fun Z a b -> Fun Z a b Source #

uncurryMany :: Fun (Add Z k) a b -> Fun Z a (Fun k a b) Source #

gunfoldF :: Data a => (forall b x. Data b => c (b -> x) -> c x) -> T_gunfold c r a Z -> c r Source #

NatIso Z 0 Source # 
Arity n => Index Z (S n) Source # 

Methods

getF :: Z -> Fun (S n) a a Source #

putF :: Z -> a -> Fun (S n) a r -> Fun (S n) a r Source #

lensF :: Functor f => Z -> (a -> f a) -> Fun (S n) a r -> Fun (S n) a (f r) Source #

type Add Z n Source # 
type Add Z n = n
type Fn Z a b Source # 
type Fn Z a b = b

data S n Source #

Successor of n

Instances

Arity n => Index Z (S n) Source # 

Methods

getF :: Z -> Fun (S n) a a Source #

putF :: Z -> a -> Fun (S n) a r -> Fun (S n) a r Source #

lensF :: Functor f => Z -> (a -> f a) -> Fun (S n) a r -> Fun (S n) a (f r) Source #

Arity n => Arity (S n) Source # 

Methods

accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t (S n) -> Fun (S n) a b Source #

applyFun :: (forall k. t (S k) -> (a, t k)) -> t (S n) -> Fn (S n) a b -> (b, t Z) Source #

applyFunM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t (S n) -> m (ContVec (S n) a, t Z) Source #

arity :: S n -> Int Source #

reverseF :: Fun (S n) a b -> Fun (S n) a b Source #

uncurryMany :: Fun (Add (S n) k) a b -> Fun (S n) a (Fun k a b) Source #

gunfoldF :: Data a => (forall b x. Data b => c (b -> x) -> c x) -> T_gunfold c r a (S n) -> c r Source #

(NatIso k ((-) n 1), (~) * (ToPeano ((-) n 1)) k, (~) * (ToPeano n) (S k), (~) Nat n ((+) 1 ((-) n 1))) => NatIso (S k) n Source # 
Index k n => Index (S k) (S n) Source # 

Methods

getF :: S k -> Fun (S n) a a Source #

putF :: S k -> a -> Fun (S n) a r -> Fun (S n) a r Source #

lensF :: Functor f => S k -> (a -> f a) -> Fun (S n) a r -> Fun (S n) a (f r) Source #

type Add (S n) k Source # 
type Add (S n) k = S (Add n k)
type Fn (S n) a b Source # 
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

construct, inspect

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

accum, applyFun, applyFunM, arity, reverseF, uncurryMany, gunfoldF

Instances

Arity Z Source # 

Methods

accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t Z -> Fun Z a b Source #

applyFun :: (forall k. t (S k) -> (a, t k)) -> t Z -> Fn Z a b -> (b, t Z) Source #

applyFunM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t Z -> m (ContVec Z a, t Z) Source #

arity :: Z -> Int Source #

reverseF :: Fun Z a b -> Fun Z a b Source #

uncurryMany :: Fun (Add Z k) a b -> Fun Z a (Fun k a b) Source #

gunfoldF :: Data a => (forall b x. Data b => c (b -> x) -> c x) -> T_gunfold c r a Z -> c r Source #

Arity n => Arity (S n) Source # 

Methods

accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t (S n) -> Fun (S n) a b Source #

applyFun :: (forall k. t (S k) -> (a, t k)) -> t (S n) -> Fn (S n) a b -> (b, t Z) Source #

applyFunM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t (S n) -> m (ContVec (S n) a, t Z) Source #

arity :: S n -> Int Source #

reverseF :: Fun (S n) a b -> Fun (S n) a b Source #

uncurryMany :: Fun (Add (S n) k) a b -> Fun (S n) a (Fun k a b) Source #

gunfoldF :: Data a => (forall b x. Data b => c (b -> x) -> c x) -> T_gunfold c r a (S n) -> c r Source #

newtype Fun n a b Source #

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

Constructors

Fun 

Fields

Instances

Arity n => Monad (Fun n a) Source # 

Methods

(>>=) :: Fun n a a -> (a -> Fun n a b) -> Fun n a b #

(>>) :: Fun n a a -> Fun n a b -> Fun n a b #

return :: a -> Fun n a a #

fail :: String -> Fun n a a #

Arity n => Functor (Fun n a) Source # 

Methods

fmap :: (a -> b) -> Fun n a a -> Fun n a b #

(<$) :: a -> Fun n a b -> Fun n a a #

Arity n => Applicative (Fun n a) Source # 

Methods

pure :: a -> Fun n a a #

(<*>) :: Fun n a (a -> b) -> Fun n a a -> Fun n a b #

(*>) :: Fun n a a -> Fun n a b -> Fun n a b #

(<*) :: Fun n a a -> Fun n a b -> Fun n a 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 #

find :: (VectorMono v, VectorElm v ~ a) => (a -> Bool) -> v -> Maybe a 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 #