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

Reintroduce compile-time checks for record/union constructors #28

Closed vil1 closed 5 years ago

vil1 commented 5 years ago

In the current schema encoding, RecordSchemas (resp. Unions) only make sense when they are built from "labelled products" (resp. "labelled sums"), ie. a product (resp. sum) whose all members are ProductTerms (resp. SumTerms).

It is necessary to (re)introduce a way to make impossible to construct records/unions with anything else than labelled products/sums.

This might be done "syntactically", by exposing methods and syntax that allow just that and nothing else (tweaking the methods' signatures in SchemaSyntax for starters), or by going down the "shapeless-like inductive type-level constraints" path (but that might prove cumbersome because of the "pattern-functorish" nature of Schema).