Safe Haskell | None |
---|
Homogeneous lists with the length encoded in the type.
This can be considered as a different implementation of Data.Tup.Tup (one which also scales for vectors/tuples longer than 9 elements)
- class (Functor v, Applicative v, Foldable v, Traversable v) => Vec v where
- vecSize :: v a -> Int
- vecToList :: v a -> [a]
- vecFromList :: [a] -> v a
- vecUndef :: v a -> a
- undefinedVec :: v a
- type Vec0 = Empty
- type Vec1 = Cons Vec0
- type Vec2 = Cons Vec1
- type Vec3 = Cons Vec2
- type Vec4 = Cons Vec3
- type Vec5 = Cons Vec4
- type Vec6 = Cons Vec5
- type Vec7 = Cons Vec6
- type Vec8 = Cons Vec7
- type Vec9 = Cons Vec8
- data Empty a = Empty
- data Cons v a = Cons a (v a)
- consUndefTail :: Vec v => Cons v a -> v a
- maybeVecFromList :: Vec f => [a] -> Maybe (f a)
- transposeVec :: (Vec f, Vec g) => f (g a) -> g (f a)
- maybeVecConcat :: (Vec f, Vec g, Vec h) => f a -> g a -> Maybe (h a)
- unsafeVecConcat :: (Vec f, Vec g, Vec h) => f a -> g a -> h a
- class (Vec u, Vec v, Vec w) => VecConcat u v w | u v -> w where
- vecConcat :: u a -> v a -> w a
- zipVecWith :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- zipVecWith3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- zipVecWith4 :: Applicative f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
- zipVec :: Applicative f => f a -> f b -> f (a, b)
- zipVec3 :: Applicative f => f a -> f b -> f c -> f (a, b, c)
- zipVec4 :: Applicative f => f a -> f b -> f c -> f d -> f (a, b, c, d)
- vec0 :: Vec0 a
- vec1 :: a -> Vec1 a
- vec2 :: a -> a -> Vec2 a
- vec3 :: a -> a -> a -> Vec3 a
- vec4 :: a -> a -> a -> a -> Vec4 a
- vec5 :: a -> a -> a -> a -> a -> Vec5 a
- vec6 :: a -> a -> a -> a -> a -> a -> Vec6 a
- vec7 :: a -> a -> a -> a -> a -> a -> a -> Vec7 a
- vec8 :: a -> a -> a -> a -> a -> a -> a -> a -> Vec8 a
- vec9 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> Vec9 a
- vecVec :: Applicative f => f a -> f a -> f (Vec2 a)
- vecVec3 :: Applicative f => f a -> f a -> f a -> f (Vec3 a)
- vecVec4 :: Applicative f => f a -> f a -> f a -> f a -> f (Vec4 a)
- vecVec5 :: Applicative f => f a -> f a -> f a -> f a -> f a -> f (Vec5 a)
The Vec
type class
class (Functor v, Applicative v, Foldable v, Traversable v) => Vec v whereSource
vecFromList :: [a] -> v aSource
undefinedVec :: v aSource
Type abbreviations for short vectors
The constructor types
Functor Empty | |
Applicative Empty | |
Foldable Empty | |
Traversable Empty | |
Vec Empty | |
(Vec Empty, Vec v) => VecConcat Empty v v | |
Eq (Empty a) | |
(Num (Empty a), Fractional a) => Fractional (Empty a) | |
Num a => Num (Empty a) | |
Eq (Empty a) => Ord (Empty a) | |
Show a => Show (Empty a) | |
Monoid a => Monoid (Empty a) | |
Storable a => Storable (Empty a) |
Cons a (v a) |
Functor v => Functor (Cons v) | |
(Functor (Cons v), Applicative v) => Applicative (Cons v) | |
Foldable v => Foldable (Cons v) | |
(Functor (Cons v), Foldable (Cons v), Traversable v) => Traversable (Cons v) | |
(Functor (Cons v), Applicative (Cons v), Foldable (Cons v), Traversable (Cons v), Vec v) => Vec (Cons v) | |
(Vec (Cons u), Vec (Cons w), Vec u, Vec v, VecConcat u v w) => VecConcat (Cons u) v (Cons w) | |
(Eq a, Eq (v a)) => Eq (Cons v a) | |
(Num (Cons v a), Fractional a, Fractional (v a), Vec v) => Fractional (Cons v a) | |
(Num a, Num (v a), Vec v) => Num (Cons v a) | |
(Eq (Cons v a), Ord a, Ord (v a)) => Ord (Cons v a) | |
(Show a, Vec v) => Show (Cons v a) | |
(Monoid a, Monoid (v a), Vec v) => Monoid (Cons v a) | |
(Storable a, Storable (v a), Vec v) => Storable (Cons v a) |
consUndefTail :: Vec v => Cons v a -> v aSource
Misc
maybeVecFromList :: Vec f => [a] -> Maybe (f a)Source
Safe version of vecFromList
.
transposeVec :: (Vec f, Vec g) => f (g a) -> g (f a)Source
Transpose a Vec of Vecs.
Concatenation
unsafeVecConcat :: (Vec f, Vec g, Vec h) => f a -> g a -> h aSource
unsafe concatenation
Zipping
zipVecWith :: Applicative f => (a -> b -> c) -> f a -> f b -> f cSource
zipVecWith3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f dSource
zipVecWith4 :: Applicative f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f eSource
zipVec :: Applicative f => f a -> f b -> f (a, b)Source
zipVec3 :: Applicative f => f a -> f b -> f c -> f (a, b, c)Source
zipVec4 :: Applicative f => f a -> f b -> f c -> f d -> f (a, b, c, d)Source
Short constructor functions
"veccing"
vecVec :: Applicative f => f a -> f a -> f (Vec2 a)Source
vecVec3 :: Applicative f => f a -> f a -> f a -> f (Vec3 a)Source
vecVec4 :: Applicative f => f a -> f a -> f a -> f a -> f (Vec4 a)Source
vecVec5 :: Applicative f => f a -> f a -> f a -> f a -> f a -> f (Vec5 a)Source