spartanz / schemaz

A purely-functional library for defining type-safe schemas for algebraic data types, providing free generators, SQL queries, JSON codecs, binary codecs, and migration from this schema definition
https://spartanz.github.io/schemaz
Apache License 2.0
164 stars 18 forks source link

SchemaZ

Gitter

Build Status Coverage Status

Goal

A purely-functional library for defining type-safe schemas for algebraic data types, providing free generators, SQL queries, JSON codecs, binary codecs, and migration from this schema definition.

Introduction & Highlights

SchemaZ defines a generic representation of algebraic data structures and combinators that turn such schema into a generic computation over arbitrary data. In other words, SchemaZ provides a way to express any computation that abstracts over the structure of data, such as:

Competition

codecs generators migrations diff/patch queries
xenomorph โœ“ โœ“ ? ๐„‚ ๐„‚
shapeless * โœ“ โœ“ ๐„‚ โœ“ ๐„‚

*: shapeless provides only the way to abstract over the structure of data, but several libraries build upon shapeless to provide the feature listed in the table.

Skeumorph is also a possible competitor, however it is focused on providing translation between different formats (Avro, Protobuf and Mu). This is achieved by using a central Schema Representation which can losslessly translate to each of the previously mentioned formats.

Background

SchemaZ shares ideas with @nuttycom's xenomorph library. The talk below presents its design.

<img src="http://img.youtube.com/vi/oRLkb6mqvVM/0.jpg" alt="Describing Data...with free applicative functors (and more)โ€”Kris Nuttycombe" width="240" height="180" border="10" />

An Haskell port of the ideas of xenomorph has also been implemented: haskell-schema.