/shapelse

Collect information about your data objects such as field structure, names, annotations, values, etc.

Primary LanguageScalaApache License 2.0Apache-2.0

Shapelse

build codecov latest

If you were looking for Shapeless, here is the link.

Shapelse (shape + else) is a small abstraction layer on top of Shapeless. As an abstraction layer it has less freedom in usage but in some cases it's more convenient to use.

Shapelse allows deriving strictly defined Shapes for your ADTs (what is ADT?).

Why? Originally, I needed to implement automatic derivation for Json Schema encoders. But then I realized that similar structure can be used in different cases, for example, if you need print your data in table view with pretty column titles. That's why it was extracted into this library.

Supported types

Currently, Shapelse supports the following types:

Type Comment
primitives Boolean, Char, String, Byte, Short, Int, Long, Float, Double
case classes (products)*
sealed traits extended by case classes (coproducts)*
Option*
List*

* Can contain any other supported types.

Implemented shape encoders

What is Shape?

Shape is a simple algebraic data type:

shape

Example

Let's say, you have the following annotation and ADT:

case class says(s: String) extends StaticAnnotation

sealed trait Animal
@says("oof") case class Dog(name: String) extends Animal
@says("meow") case class Cat(name: String) extends Animal

TBD