vec

Vec: length-indexed (sized) list https://github.com/phadej/vec

Latest on Hackage:0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Oleg Grenrus
Maintained by Oleg.Grenrus

This package provides length indexed lists, i.e. Vec.

data Vec n a where
VNil  :: Vec 'Nat.Z a
(:::) :: a -> Vec n a -> Vec ('Nat.S n) a

The functions are implemented in three flavours:

  • naive: with explicit recursion. It's simple, constraint-less, yet slow.

  • pull: using Fin n -> a representation, which fuses well, but makes some programs hard to write. And

  • inline: which exploits how GHC dictionary inlining works, unrolling recursion if the size of Vec is known statically.

As best approach depends on the application, vec doesn't do any magic transformation. Benchmark your code.

Differences to other packages:

  • linear has V type, which uses Vector from vector package as backing store. Vec is a real GADT, but tries to provide as many useful instances (upto lens).

  • sized-vector depends on singletons package. vec isn't light on dependencies either, but try to provide wide GHC support.

  • sized also depends on a singletons package. The Sized f n a type is generalisation of linear's V for any ListLike.

  • clash-prelude is a kitchen sink package, which has CLaSH.Sized.Vector module. Also depends on singletons.

Changes

Revision history for boring

0

  • First version. Released on an unsuspecting world.
comments powered byDisqus