ekmett / linear

Low-dimensional linear algebra primitives for Haskell.
http://hackage.haskell.org/package/linear
Other
201 stars 50 forks source link

Constant vectors in Linear.V #130

Closed jachymb closed 7 years ago

jachymb commented 7 years ago

I would find it useful to have a function like this

constV :: forall a n. KnownNat n => a -> V n a

which creates a vector of given (type-level) length with some default value. It can be implemented quite easily:

constV = fromJust . fromVector . replicate (reflectDim (Proxy :: Proxy n))

but I find this somewhat ugly due to the use of fromJust. It would be nicer to have a library function which does not need this.

cchalmers commented 7 years ago

Your constV is simply pure.

glguy commented 7 years ago

The fix for this would be to add documentation somewhere explaining how to use the library.