All Projects → tobgu → peds

tobgu / peds

Licence: MIT license
Type safe persistent/immutable data structures for Go

Programming Languages

go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to peds

Pyrsistent
Persistent/Immutable/Functional data structures for Python
Stars: ✭ 1,621 (+2743.86%)
Mutual labels:  immutable, functional, datastructures
Phpfn
Functional PHP Toolstet: Centralized monorepository for all libraries
Stars: ✭ 19 (-66.67%)
Mutual labels:  immutable, functional
Fpp
Functional PHP Preprocessor - Generate Immutable Data Types
Stars: ✭ 282 (+394.74%)
Mutual labels:  immutable, functional
Html
A Virtual DOM based templating-engine for PHP
Stars: ✭ 86 (+50.88%)
Mutual labels:  immutable, functional
venum
Verifiably better, validated Enum for Python
Stars: ✭ 31 (-45.61%)
Mutual labels:  immutable, functional
Switzerland
🇨🇭Switzerland takes a functional approach to Web Components by applying middleware to your components. Supports Redux, attribute mutations, CSS variables, React-esque setState/state, etc… out-of-the-box, along with Shadow DOM for style encapsulation and Custom Elements for interoperability.
Stars: ✭ 261 (+357.89%)
Mutual labels:  immutable, functional
Immutable Tuple
Immutable finite list objects with constant-time equality testing (===) and no memory leaks.
Stars: ✭ 29 (-49.12%)
Mutual labels:  immutable, functional
Umbrella
"A collection of functional programming libraries that can be composed together. Unlike a framework, thi.ng is a suite of instruments and you (the user) must be the composer of. Geared towards versatility, not any specific type of music." — @loganpowell via Twitter
Stars: ✭ 2,186 (+3735.09%)
Mutual labels:  functional, datastructures
Typed
The TypeScript Standard Library
Stars: ✭ 124 (+117.54%)
Mutual labels:  immutable, functional
transmute
kind of like lodash but works with Immutable
Stars: ✭ 35 (-38.6%)
Mutual labels:  immutable, functional
grand central
State-management and action-dispatching for Ruby apps
Stars: ✭ 20 (-64.91%)
Mutual labels:  immutable, functional
finger-tree
🌵 Finger tree data structure for JavaScript
Stars: ✭ 20 (-64.91%)
Mutual labels:  immutable, functional
fastener
Functional Zipper for manipulating JSON
Stars: ✭ 54 (-5.26%)
Mutual labels:  immutable, functional
Typed Immutable
Immutable and structurally typed data
Stars: ✭ 263 (+361.4%)
Mutual labels:  immutable, functional
treecko
A collection of functional and immutable helpers for working with tree data structures.
Stars: ✭ 31 (-45.61%)
Mutual labels:  immutable, functional
Partial.lenses
Partial lenses is a comprehensive, high-performance optics library for JavaScript
Stars: ✭ 846 (+1384.21%)
Mutual labels:  immutable, functional
Dataframe Js
A javascript library providing a new data structure for datascientists and developpers
Stars: ✭ 376 (+559.65%)
Mutual labels:  functional, datastructures
Lens
A utility for working with nested data structures.
Stars: ✭ 104 (+82.46%)
Mutual labels:  functional, datastructures
hawkweed
Yet another implementation of missing functions for Python
Stars: ✭ 20 (-64.91%)
Mutual labels:  functional, datastructures
js-data-structures
🌿 Data structures for JavaScript
Stars: ✭ 56 (-1.75%)
Mutual labels:  immutable, functional

Statically type safe persistent/immutable/functional data structures for Go.

Inspired by Clojures data structures and the work done in Pyrsistent for Python.

This is an experiment in how close to generics that code generation can take you. There's currently a vector, a slice, a map and a set implemented.

What's a persistent data structure?

Despite their name persistent data structures usually don't refer to data structures stored on disk. Instead they are immutable data structures which are copy-on-write. Eg. whenever you mutate a persistent data structure a new one is created that contains the data in the original plus the mutation while the original is left untouched.

To make this reasonably efficient, "structural sharing" is used between the data structures. Here's a good introduction to how this is done in Clojure: http://hypirion.com/musings/understanding-persistent-vector-pt-1

Installation

go get github.com/tobgu/peds/cmd/peds

Usage

Generate statically type safe code for persistent data structures.

USAGE
peds

FLAGS        EXAMPLE
  -file      path/to/file.go
  -imports   import1;import2
  -maps      Map1<int,string>;Map2<float,int>
  -pkg       package_name
  -sets      Set1<int>
  -vectors   Vec1<int>

Examples

There are a couple of generated example collections in examples/collections.go.

The go:generate command used can be found in examples/types.go.

This illustrates the core usage pattern:

//go:generate peds -vectors=IntVector<int> -pkg=my_collections -file=collections/my_collections_gen.go

// Create a new vector
v := my_collections.NewIntVector(1, 2, 3)

// Create a copy of v with the first element set to 55, v is left untouched.
v2 := v.Set(0, 55)

Godoc

Generic types

https://godoc.org/github.com/tobgu/peds/internal/generic_types

Generated examples

https://godoc.org/github.com/tobgu/peds/examples

Experiences

There's an experience report based on the implementation of this library.

Caveats

  • Even though the data structures are immutable by most means it is not possible to use them as keys in hash maps for example. This is because they internally make use of slices, which are not comparable in Go.

Possible improvements

  • Investigate implementing the Map as a CHAMP tree.
  • Introspection of the contained types possible to refine the hash functions?
  • Get rid of Python dependency for developing peds (not needed to build or use peds).

Regenerate templates and run tests

make test

Want to contribute?

Great! Write an issue and let the discussions begin! Then file a PR!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].