• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Haskell
  • License
    MIT License
  • Created over 8 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast binary serialization in Haskell

store

The 'store' package provides efficient binary serialization. There are a couple features that particularly distinguish it from most prior Haskell serialization libraries:

  • Its primary goal is speed. By default, direct machine representations are used for things like numeric values (Int, Double, Word32, etc) and buffers (Text, ByteString, Vector, etc). This means that much of serialization uses the equivalent of memcpy.

    We have plans for supporting architecture independent serialization - see #36 and #31. This plan makes little endian the default, so that the most common endianness has no overhead.

    • Another way that the serialization behavior can vary is if integer-simple is used instead of GHC's default of using GMP. Integer serialized with the integer-simple flag enabled are not compatible with those serialized without the flag enabled.
  • Instead of implementing lazy serialization / deserialization involving multiple input / output buffers, peek and poke always work with a single buffer. This buffer is allocated by asking the value for its size before encoding. This simplifies the encoding logic, and allows for highly optimized tight loops.

  • store can optimize size computations by knowing when some types always use the same number of bytes. This allows us to compute the byte size of a Vector Int32 by just doing length v * 4.

It also features:

  • Optimized serialization instances for many types from base, vector, bytestring, text, containers, time, template-haskell, and more.

  • TH and GHC Generics based generation of Store instances for datatypes.

  • TH generation of testcases.

  • Utilities for streaming encoding / decoding of Store encoded messages, via the store-streaming package.

Gotchas

Store is best used for communication between trusted processes and local caches. It can certainly be used for other purposes, but the builtin set of instances have some gotchas to be aware of:

  • Store's builtin instances serialize in a format which depends on machine endianness.

  • Store's builtin instances trust the data when deserializing. For example, the deserialization of Vector will read the vector's length from the first 8 bytes. It will then allocate enough memory to store all the elements. Malicious or malformed input could cause allocation of large amounts of memory. See issue #122.

  • Serialization may vary based on the version of datatypes. For example, Text serialized from text < 2 will not be compatible with Text from text >= 2, because the internal representation switched from UTF-16 to UTF-8.

Blog posts

More Repositories

1

todoist-shortcuts

Browser extension which adds comprehensive keyboard shortcuts to Todoist, beyond what is offered by Todoist itself
JavaScript
313
star
2

roam-navigator

JavaScript
37
star
3

mgsloan-dotfiles

Linux and xmonad configuration files
Shell
21
star
4

crdt

Implementation of Haskell CRDTs (Commutative Replicated Data Types)
Haskell
13
star
5

rex

A Haskell quasi-quoter for typeful results of regex captures.
Haskell
12
star
6

8760-hours-template

Markdown templates based on Alex Vermeer's "8760 hours"
Shell
11
star
7

instance-templates

A Haskell feature proposal with TH prototype
Haskell
10
star
8

api-compat

Haskell
7
star
9

quasi-extras

Quasi-quoters for better construction and pattern matching TH ASTs, desugaring utilities, and a demonstration of overloading function application
Haskell
7
star
10

th-orphans

Orphan instances for Template Haskell datatypes
Haskell
6
star
11

th-reify-many

Recurseively reify template haskell datatype info
Haskell
6
star
12

ast-vis

Little Haskell AST visualizer
Haskell
6
star
13

mgsloan-site

Source and site generator for https://mgsloan.com
HTML
5
star
14

css-overlap

JavaScript
5
star
15

diagrams-ghci

Editable Haskell expressions yielding live-updating diagrams.
Haskell
5
star
16

panopti

Haskell type system visualizer and structure editor
Haskell
3
star
17

prana

Interpreter for GHC Haskell
Haskell
3
star
18

sproto

Simple &amp; clean protocol buffers implementation in haskell
Haskell
3
star
19

apply-unordered

Experiments in type-directed function application and argument reordering
Haskell
3
star
20

kiimote

Integrates the kinect(tm) and wiimote(tm) devices to provide versatile 6-degree-of-freedom controllers
C++
3
star
21

explain-instance

Haskell
3
star
22

curve

Haskell geometry library
Haskell
3
star
23

newtype-th

Template Haskell Newtype Derivation
Haskell
3
star
24

cse481

C#
2
star
25

toy-gtk

Provides boilerplate for simple interactive GTK / Cairo applications.
Haskell
2
star
26

HaskellStarProxy

Haskell starcraft AI proxy client
2
star
27

ainav

Rust
2
star
28

toy-interface

Haskell
2
star
29

lenq

Quasi-quoters for easy lenses and bijections
Haskell
2
star
30

plumbers

Pointless plumbing combinators
Haskell
2
star
31

ghcjs-typescript

Haskell
2
star
32

zeroth

Haskell
2
star
33

Panopticode

WIP, presently non functional code visualizer / analysis / refactoring engine
Haskell
1
star
34

storepats

Haskell
1
star
35

mzr

Rust
1
star
36

parenthesize

Haskell
1
star
37

themplates

Allows upgrading a parser to a parser with splices.
Haskell
1
star
38

stack-ide-spacemacs

WIP spacemacs layer
Emacs Lisp
1
star
39

squarespace-escape-suppressor

JavaScript
1
star
40

unblock-with-intention

JavaScript
1
star
41

BlockSynth

WIP Kinect sound system
C++
1
star
42

toy-gtk-diagrams

Backend-specific functions and instances for using toy-gtk with toy-diagrams.
Haskell
1
star
43

ActiveHs

Code visualization / interaction system, Cairo-based fork of ActiveHs intended for very different purposes.
Haskell
1
star
44

misc

Haskell
1
star
45

yesod-media-simple

Simple display of media types, served by yesod
Haskell
1
star
46

mgsloan.github.io

Static content for https://mgsloan.com
HTML
1
star
47

gmail-label-switch-shortcuts

Adds keyboard shortcuts to select next / previous label in GMail
JavaScript
1
star