Safe Haskell | Safe-Inferred |
---|
Data.Vector.Fixed.Internal
Description
Type classes for generic vectors. This module exposes type classes and auxiliary functions needed to write generic functions not present in the module Data.Vector.Fixed.
Implementation is based on http://unlines.wordpress.com/2010/11/15/generics-for-small-fixed-size-vectors/
- data Z
- data S n
- type N1 = S Z
- type N2 = S N1
- type N3 = S N2
- type N4 = S N3
- type N5 = S N4
- type N6 = S N5
- type family Fn n a b
- newtype Fun n a b = Fun (Fn n a b)
- class Arity n where
- accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t n -> Fn n a b
- accumM :: Monad m => (forall k. t (S k) -> a -> m (t k)) -> (t Z -> m b) -> m (t n) -> Fn n a (m b)
- apply :: (forall k. t (S k) -> (a, t k)) -> t n -> Fn n a b -> b
- applyM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t n -> Fn n a (m b) -> m b
- arity :: n -> Int
- type family Dim v
- class Arity (Dim v) => Vector v a where
- class (Vector (v n) a, Dim (v n) ~ n) => VectorN v n a
- length :: forall v a. Arity (Dim v) => v a -> Int
- newtype Id a = Id {
- runID :: a
Type-level naturals
Synonyms for small numerals
N-ary functions
Newtype wrapper which is used to make Fn
injective.
Type class for handling n-ary functions.
Methods
Arguments
:: (forall k. t (S k) -> a -> t k) | Fold function |
-> (t Z -> b) | Extract result of fold |
-> t n | Initial value |
-> Fn n a b | Reduction function |
Left fold over n elements exposed as n-ary function.
Arguments
:: Monad m | |
=> (forall k. t (S k) -> a -> m (t k)) | Fold function |
-> (t Z -> m b) | Extract result of fold |
-> m (t n) | Initial value |
-> Fn n a (m b) | Reduction function |
Monadic left fold.
Arguments
:: (forall k. t (S k) -> (a, t k)) | Get value to apply to function |
-> t n | Initial value |
-> Fn n a b | N-ary function |
-> b |
Apply all parameters to the function.
Arguments
:: Monad m | |
=> (forall k. t (S k) -> m (a, t k)) | Get value to apply to function |
-> t n | Initial value |
-> Fn n a (m b) | N-ary function |
-> m b |
Monadic apply
Arity of function.
Vector type class
class Arity (Dim v) => Vector v a whereSource
Type class for vectors with fixed length.
Methods
construct :: Fun (Dim v) a (v a)Source
N-ary function for creation of vectors.
inspect :: v a -> Fun (Dim v) a b -> bSource
Deconstruction of vector.
Instances
RealFloat a => Vector Complex a | |
~ * b a => Vector ((,) b) a | |
Arity n => Vector (VecList n) a | |
Arity n => Vector (Vec n) a | |
(Arity n, Prim a) => Vector (Vec n) a | |
Unbox n a => Vector (Vec n) a | |
(Arity n, Storable a) => Vector (Vec n) a | |
(~ * b a, ~ * c a) => Vector ((,,) b c) a | |
(~ * b a, ~ * c a, ~ * d a) => Vector ((,,,) b c d) a | |
(~ * b a, ~ * c a, ~ * d a, ~ * e a) => Vector ((,,,,) b c d e) a |
class (Vector (v n) a, Dim (v n) ~ n) => VectorN v n a Source
Vector parametrized by length. In ideal world it should be:
forall n. (Arity n, Vector (v n) a, Dim (v n) ~ n) => VectorN v a
Alas polymorphic constraints aren't allowed in haskell.