Skip to content
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
Branch: prototyping
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add sample `.github/CODEOWNERS` file Jul 8, 2018
microsite/src/main Update recursive-datatypes.md Mar 8, 2019
modules removed unnecessary parameter in generic derivations. Not sure if Dec… Mar 19, 2019
project Add coverage measurement and reporting (Fixes #55) (#57) Mar 19, 2019
.gitignore
.scalafmt.conf #6 Flesh out the GenModule (#20) Sep 11, 2018
.travis.yml
DESIGN_NOTES.md #6 Flesh out the GenModule (#20) Sep 11, 2018
LICENSE Add license (Apache 2) Jul 8, 2018
README.md Add coverage measurement and reporting (Fixes #55) (#57) Mar 19, 2019
build.sbt Initialize documentation microsite (#34) Feb 11, 2019
publishMicrosite.sh Initialize documentation microsite (#34) Feb 11, 2019
travis-deploy-key.enc

README.md

scalaz-schema

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

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

  • Codecs: given a serial format (binary, JSON, etc.) and the schema of a data structure (say, an ADT) we can derive a codec for that data structure and serial format.
  • Data Generators: given any schema we can derive random data generators (eg. scalacheck's Gen) that produce data satisfying that schema.
  • Schema/Data Migrations: since schemas are values, we can easily verify whether two versions of a schema are forward/backward compatible and provide a generic way to upgrade/downgrade data from one version of the schema to the other.
  • Diffing/Patching: given a schema we can generically compute the difference between two pieces of data satisfying that schema. In the same spirit, we have generic way to apply patches to arbitrary data structures.
  • Queries: knowing a schema, we can produce SQL queries to interact with a database that holds an instance of (the SQL version of) that schema.

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

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

Describing Data...with free applicative functors (and more)—Kris Nuttycombe

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

You can’t perform that action at this time.