Module
Data.Vec
- Package
- purescript-sized-vectors
- Repository
- bodil/purescript-sized-vectors
#Vec Source
newtype Vec s a
Vec s a
is an array with a fixed size s
defined at the type level.
Instances
(Generic a a') => Generic (Vec s a) _
(Eq a) => Eq (Vec s a)
Functor (Vec s)
Foldable (Vec s)
FunctorWithIndex Int (Vec s)
FoldableWithIndex Int (Vec s)
TraversableWithIndex Int (Vec s)
Traversable (Vec s)
(EncodeJson a) => EncodeJson (Vec s a)
(DecodeJson a) => DecodeJson (Vec s a)
(Arbitrary a, Nat s) => Arbitrary (Vec s a)
(Coarbitrary a, Nat s) => Coarbitrary (Vec s a)
Apply (Vec s)
(Nat s) => Applicative (Vec s)
(Nat s) => Bind (Vec s)
(Nat s) => Monad (Vec s)
(Nat s) => Distributive (Vec s)
(Nat s, Show a) => Show (Vec s a)
(Semiring a, Nat s) => Semiring (Vec s a)
(Ring a, Nat s) => Ring (Vec s a)
(CommutativeRing a, Nat s) => CommutativeRing (Vec s a)
(Semigroup a, Nat s) => Semigroup (Vec s a)
(Monoid a, Nat s) => Monoid (Vec s a)
#replicate' Source
replicate' :: forall a s. Nat s => a -> Vec s a
#toUnfoldable Source
toUnfoldable :: forall a s f. Unfoldable f => Nat s => Vec s a -> f a
Convert a vector into any Unfoldable
.
#index Source
index :: forall a s i. Nat i => Lt i s => Vec s a -> i -> a
Get the element at a given index inside a vector. Index out of bounds errors are caught at compile time.
Example:
myVector = 1 +> 2 +> 3 +> 4 +> empty
value = index myVector d2
-- value == 3
value = index myVector d4
-- out of bounds so does not type check
- Modules
- Data.
Vec