Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/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://github.com/spartanz/schemaz
Last synced: 2 months ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/spartanz/schemaz
- Owner: spartanz
- License: apache-2.0
- Created: 2018-07-08T05:49:57.000Z (over 6 years ago)
- Default Branch: prototyping
- Last Pushed: 2020-01-28T10:36:26.000Z (almost 5 years ago)
- Last Synced: 2024-04-09T10:35:38.776Z (9 months ago)
- Language: Scala
- Homepage: https://spartanz.github.io/schemaz
- Size: 1.23 MB
- Stars: 164
- Watchers: 30
- Forks: 18
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-ccamel - 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 (Scala)
README
# SchemaZ
[![Gitter](https://badges.gitter.im/spartanz/schemaz.svg)](https://gitter.im/spartanz/schemaz?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url]
[build-image]: http://img.shields.io/travis/spartanz/schemaz/prototyping.svg
[build-url]: https://travis-ci.org/spartanz/schemaz[coverage-image]: https://img.shields.io/codecov/c/github/spartanz/schemaz/prototyping.svg
[coverage-url]: https://codecov.io/github/spartanz/schemaz?branch=prototyping## 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:
* 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](https://github.com/higherkindness/skeuomorph) 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.
## BackgroundSchemaZ shares ideas with @nuttycom's [xenomorph](https://github.com/nuttycom/xenomorph) library. The talk below presents its design.
An Haskell port of the ideas of xenomorph has also been implemented: [haskell-schema](https://github.com/alonsodomin/haskell-schema).