Copyright | (C) 2012-2015 Edward Kmett |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | Trustworthy |

Language | Haskell98 |

n-D Vectors

## Synopsis

- newtype V n a = V {}
- int :: Int -> TypeQ
- dim :: forall n a. Dim n => V n a -> Int
- class Dim n where
- reflectDim :: p n -> Int

- reifyDim :: Int -> (forall (n :: *). Dim n => Proxy n -> r) -> r
- reifyVector :: forall a r. Vector a -> (forall (n :: *). Dim n => V n a -> r) -> r
- reifyDimNat :: Int -> (forall (n :: Nat). KnownNat n => Proxy n -> r) -> r
- reifyVectorNat :: forall a r. Vector a -> (forall (n :: Nat). KnownNat n => V n a -> r) -> r
- fromVector :: forall n a. Dim n => Vector a -> Maybe (V n a)
- class Finite v where
- _V :: (Finite u, Finite v) => Iso (V (Size u) a) (V (Size v) b) (u a) (v b)
- _V' :: Finite v => Iso (V (Size v) a) (V (Size v) b) (v a) (v b)

# Documentation

## Instances

FunctorWithIndex Int (V n) # | |

FoldableWithIndex Int (V n) # | |

Defined in Linear.V | |

TraversableWithIndex Int (V n) # | |

Defined in Linear.V itraverse :: Applicative f => (Int -> a -> f b) -> V n a -> f (V n b) # itraversed :: IndexedTraversal Int (V n a) (V n b) a b # | |

(Dim n, Unbox a) => Vector Vector (V n a) # | |

Defined in Linear.V basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (V n a) -> m (Vector (V n a)) # basicUnsafeThaw :: PrimMonad m => Vector (V n a) -> m (Mutable Vector (PrimState m) (V n a)) # basicLength :: Vector (V n a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (V n a) -> Vector (V n a) # basicUnsafeIndexM :: Monad m => Vector (V n a) -> Int -> m (V n a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (V n a) -> Vector (V n a) -> m () # | |

(Dim n, Unbox a) => MVector MVector (V n a) # | |

Defined in Linear.V basicLength :: MVector s (V n a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (V n a) -> MVector s (V n a) # basicOverlaps :: MVector s (V n a) -> MVector s (V n a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (V n a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (V n a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> V n a -> m (MVector (PrimState m) (V n a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (V n a) -> Int -> m (V n a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (V n a) -> Int -> V n a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (V n a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (V n a) -> V n a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (V n a) -> MVector (PrimState m) (V n a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (V n a) -> MVector (PrimState m) (V n a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (V n a) -> Int -> m (MVector (PrimState m) (V n a)) # | |

Generic1 (V n :: Type -> Type) # | |

Dim n => Dim (V n a :: Type) # | |

Defined in Linear.V reflectDim :: p (V n a) -> Int # | |

Dim n => Monad (V n) # | |

Functor (V n) # | |

Dim n => MonadFix (V n) # | |

Dim n => Applicative (V n) # | |

Foldable (V n) # | |

Defined in Linear.V fold :: Monoid m => V n m -> m # foldMap :: Monoid m => (a -> m) -> V n a -> m # foldr :: (a -> b -> b) -> b -> V n a -> b # foldr' :: (a -> b -> b) -> b -> V n a -> b # foldl :: (b -> a -> b) -> b -> V n a -> b # foldl' :: (b -> a -> b) -> b -> V n a -> b # foldr1 :: (a -> a -> a) -> V n a -> a # foldl1 :: (a -> a -> a) -> V n a -> a # elem :: Eq a => a -> V n a -> Bool # maximum :: Ord a => V n a -> a # | |

Traversable (V n) # | |

Dim n => Distributive (V n) # | |

Dim n => Representable (V n) # | |

Eq1 (V n) # | |

Ord1 (V n) # | |

Dim n => Read1 (V n) # | |

Show1 (V n) # | |

Dim n => MonadZip (V n) # | |

Dim n => Serial1 (V n) # | |

Defined in Linear.V serializeWith :: MonadPut m => (a -> m ()) -> V n a -> m () # deserializeWith :: MonadGet m => m a -> m (V n a) # | |

Dim n => Hashable1 (V n) # | |

Apply (V n) # | |

Bind (V n) # | |

Dim n => Additive (V n) # | |

Dim n => Metric (V n) # | |

Finite (V n) # | |

Dim n => Trace (V n) # | |

Dim n => Affine (V n) # | |

(Bounded a, Dim n) => Bounded (V n a) # | |

Eq a => Eq (V n a) # | |

(Dim n, Floating a) => Floating (V n a) # | |

(Dim n, Fractional a) => Fractional (V n a) # | |

(Typeable (V n), Typeable (V n a), Dim n, Data a) => Data (V n a) # | |

Defined in Linear.V gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V n a -> c (V n a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V n a) # dataTypeOf :: V n a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (V n a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V n a)) # gmapT :: (forall b. Data b => b -> b) -> V n a -> V n a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V n a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V n a -> r # gmapQ :: (forall d. Data d => d -> u) -> V n a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> V n a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # | |

(Dim n, Num a) => Num (V n a) # | |

Ord a => Ord (V n a) # | |

Read a => Read (V n a) # | |

Show a => Show (V n a) # | |

Generic (V n a) # | |

(Dim n, Storable a) => Storable (V n a) # | |

(Dim n, Binary a) => Binary (V n a) # | |

(Dim n, Serial a) => Serial (V n a) # | |

(Dim n, Serialize a) => Serialize (V n a) # | |

NFData a => NFData (V n a) # | |

Hashable a => Hashable (V n a) # | |

(Dim n, Unbox a) => Unbox (V n a) # | |

Defined in Linear.V | |

Ixed (V n a) # | |

(Dim n, Epsilon a) => Epsilon (V n a) # | |

Each (V n a) (V n b) a b # | |

1 <= n => Field1 (V n a) (V n a) a a # | |

2 <= n => Field2 (V n a) (V n a) a a # | |

3 <= n => Field3 (V n a) (V n a) a a # | |

4 <= n => Field4 (V n a) (V n a) a a # | |

5 <= n => Field5 (V n a) (V n a) a a # | |

6 <= n => Field6 (V n a) (V n a) a a # | |

7 <= n => Field7 (V n a) (V n a) a a # | |

8 <= n => Field8 (V n a) (V n a) a a # | |

9 <= n => Field9 (V n a) (V n a) a a # | |

10 <= n => Field10 (V n a) (V n a) a a # | |

11 <= n => Field11 (V n a) (V n a) a a # | |

12 <= n => Field12 (V n a) (V n a) a a # | |

13 <= n => Field13 (V n a) (V n a) a a # | |

14 <= n => Field14 (V n a) (V n a) a a # | |

15 <= n => Field15 (V n a) (V n a) a a # | |

16 <= n => Field16 (V n a) (V n a) a a # | |

17 <= n => Field17 (V n a) (V n a) a a # | |

18 <= n => Field18 (V n a) (V n a) a a # | |

19 <= n => Field19 (V n a) (V n a) a a # | |

data MVector s (V n a) # | |

type Rep1 (V n :: Type -> Type) # | |

type Rep (V n) # | |

type Size (V n) # | |

type Diff (V n) # | |

Defined in Linear.Affine | |

type Rep (V n a) # | |

data Vector (V n a) # | |

type Index (V n a) # | |

type IxValue (V n a) # | |

This can be used to generate a template haskell splice for a type level version of a given `int`

.

This does not use GHC TypeLits, instead it generates a numeric type by hand similar to the ones used in the "Functional Pearl: Implicit Configurations" paper by Oleg Kiselyov and Chung-Chieh Shan.

`instance Num (Q Exp)`

provided in this package allows writing `$(3)`

instead of `$(int 3)`

. Sometimes the two will produce the same
representation (if compiled without the `-DUSE_TYPE_LITS`

preprocessor
directive).

reflectDim :: p n -> Int #

reifyVector :: forall a r. Vector a -> (forall (n :: *). Dim n => V n a -> r) -> r #

## Instances

Finite Complex # | |

Finite V1 # | |

Finite V2 # | |

Finite V3 # | |

Finite V4 # | |

Finite V0 # | |

Finite Quaternion # | |

Defined in Linear.Quaternion type Size Quaternion :: Nat # toV :: Quaternion a -> V (Size Quaternion) a # fromV :: V (Size Quaternion) a -> Quaternion a # | |

Finite Plucker # | |

Finite f => Finite (Point f) # | |

Finite (V n) # | |