GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - haskell/vector: An efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework .

BranchesTags
Open more actions menu

Latest commit

 

History

1,423 Commits
1,423 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
old-testsuite
old-testsuite
 
 
vector-bench-papi
vector-bench-papi
 
 
vector-stream
vector-stream
 
 
vector
vector
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
cabal.project
cabal.project
 
 

Repository files navigation

The vector package Build Status

Vector is a collection of efficient Int-indexed array implementations: boxed, unboxed, storable, and primitive vectors (all can be mutable or immutable). The package features a generic API, polymorphic in vector type, and implements stream fusion, a powerful optimisation framework that can help eliminate intermediate data structures.

Table of Contents

  • Tutorial
  • Vector vs Array
  • Vectors Available in the Package
  • Stream Fusion

Tutorial

A beginner-friendly tutorial for vectors can be found on MMHaskell.

If you have already started your adventure with vectors, the tutorial on Haskell Wiki covers more ground.

Vector vs Array

Arrays are data structures that can store a multitude of elements and allow immediate access to every one of them. However, they are often seen as legacy constructs that are rarely used in modern Haskell. Even though Haskell has a built-in Data.Array module, arrays might be a bit overwhelming to use due to their complex API. Conversely, vectors incorporate the array’s O(1) access to elements with a much friendlier API of lists. Since they allow for framework optimisation via loop fusion, vectors emphasise efficiency and keep a rich interface. Unless you’re confident with arrays, it’s well-advised to use vectors when looking for a similar functionality.

Vectors Available in the Package

Lazy boxed vectors (Data.Vector) store each of their elements as a pointer to a heap-allocated value. Because of indirection, lazy boxed vectors are slower in comparison to unboxed vectors.

Strict boxed vectors (Data.Vector.Strict) contain elements that are strictly evaluated.

Unboxed vectors (Data.Vector.Unboxed) determine an array's representation from its elements' type. For example, vector of primitive types (e.g. Int) will be backed by primitive array while vector of product types by structure of arrays. They are quite efficient due to the unboxed representation they use.

Storable vectors (Data.Vector.Storable) are backed by pinned memory, i.e., they cannot be moved by the garbage collector. Their primary use case is C FFI.

Primitive vectors (Data.Vector.Primitive) are backed by simple byte array and can store only data types that are represented in memory as a sequence of bytes without a pointer, i.e., they belong to the Prim type class, e.g., Int, Double, etc. It's advised to use unboxed vectors if you're looking for the performance of primitive vectors, but more versality.

Stream Fusion

An optimisation framework used by vectors, stream fusion is a technique that merges several functions into one and prevents creation of intermediate data structures. For example, the expression sum . filter g . map f won't allocate temporary vectors if compiled with optimisations.

About

An efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework .

Resources

Readme
License
Activity
Custom properties

Stars

404 stars

Watchers

22 watching

Forks

146 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.