| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
NumHask.Vector
Contents
Description
Two different classes are supplied:
Vectorwhere shape information is held at the type level, andSomeVectorwhere shape is held at the value level.
- newtype Vector n a = Vector {}
- data SomeVector a = SomeVector Int (Vector a)
- newtype ShapeV = ShapeV {}
- someVector :: KnownNat r => Vector (r :: Nat) a -> SomeVector a
- unsafeToVector :: SomeVector a -> Vector (r :: Nat) a
- toVector :: forall a r. KnownNat r => SomeVector a -> Maybe (Vector (r :: Nat) a)
Documentation
a one-dimensional array where shape is specified at the type level
The main purpose of this, beyond safe typing, is to supply the Representable instance with an initial object.
A Boxed Vector is used underneath for efficient slicing, but this may change or become polymorphic in the future.
Instances
| Functor (Vector n) Source # | |
| Foldable (Vector n) Source # | |
| KnownNat n => Distributive (Vector n) Source # | |
| KnownNat n => Representable (Vector n) Source # | |
| KnownNat n => Naperian (Vector n) Source # | |
| KnownNat n => HasShape (Vector n) Source # | |
| (KnownNat n, AdditiveUnital a) => IsList (Vector n a) Source # | pads with |
| Eq a => Eq (Vector n a) Source # | |
| Ord a => Ord (Vector n a) Source # | |
| (Show a, KnownNat n) => Show (Vector n a) Source # | |
| (KnownNat n, Arbitrary a, AdditiveUnital a) => Arbitrary (Vector n a) Source # | |
| type Rep (Vector n) Source # | |
| type Shape (Vector n) Source # | |
| type Item (Vector n a) Source # | |
data SomeVector a Source #
a one-dimensional array where shape is specified at the value level
Use this to avoid type-level hasochism by demoting a Vector with someVector
Constructors
| SomeVector Int (Vector a) |
Instances
| Functor SomeVector Source # | |
| Foldable SomeVector Source # | |
| HasShape SomeVector Source # | |
| IsList (SomeVector a) Source # | |
| Eq a => Eq (SomeVector a) Source # | |
| Ord a => Ord (SomeVector a) Source # | |
| Show a => Show (SomeVector a) Source # | |
| Arbitrary a => Arbitrary (SomeVector a) Source # | |
| type Shape SomeVector Source # | |
| type Item (SomeVector a) Source # | |
used to get sensible arbitrary instances of SomeVector
Conversion
someVector :: KnownNat r => Vector (r :: Nat) a -> SomeVector a Source #
convert from a Vector to a SomeVector
unsafeToVector :: SomeVector a -> Vector (r :: Nat) a Source #
convert from a SomeVector to a Vector with no shape check
toVector :: forall a r. KnownNat r => SomeVector a -> Maybe (Vector (r :: Nat) a) Source #
convert from a SomeVector to a Vector, checking shape