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

Context free algebras #36

Closed GrafBlutwurst closed 5 years ago

GrafBlutwurst commented 5 years ago

I think we're hitting the limit of scalac I only got the scala compiler to shut up by expicitly disabling erasure warning though. regular patterns are not possible because the compiler cannot infer the types correctly and adding the types by hand triggers erasure warnings.

vil1 commented 5 years ago

Kickly looking from my phone. This looks good, but it needs at least a test for the contravariant case (what about an interpreter for Show?)

GrafBlutwurst commented 5 years ago

Good Idea. I was looking for a contravariant functor but couldn't come up with an example. show is great.

GrafBlutwurst commented 5 years ago

the encoding of Option[A] as A \/ Unit does not yield very pretty results.

vil1 commented 5 years ago

the encoding of Option[A] as A \/ Unit does not yield very pretty results.

Mind sharing an example?

GrafBlutwurst commented 5 years ago

Frankly I'm also not quite happy with having to interject these generic derivations through inheritance. But I haven't found a good way to pass in the module in another way