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

Flesh out the GenModule #6

Closed vil1 closed 6 years ago

vil1 commented 6 years ago

In order to see how far we can go with our current approach, we need to make sure the current Schema AST allows for concrete features like giving free scalacheck Gen instance from a schema.

That is, provided we have Gen instances for all the primitive types in a schema, we need to produce a Gen for the whole schema.

The (commented out) signature for gen in modules/scalacheck/src/main/scala/GenModule.scala might need to be adapted to fit that purpose.

jkobejs commented 6 years ago

I would like to take this one.

vil1 commented 6 years ago

I think it would be highly beneficial if you were able to provide this functionality by means of a Schema ~> Gen natural transformation. Doing so will probably give us insights about ways to later generalize this to Schema ~> F (telling us which typeclass instances are required for F for example).

vil1 commented 6 years ago

Hi @josipgrgurica, did you make any progress on this, do you need some help?

jkobejs commented 6 years ago

Hi @vil1, I stuck on part where I need to create record from schema and field values. I saw that record schema is defined in terms of applicative in xenomorph, should I try to add it in our record schema?

vil1 commented 6 years ago

Well, I'm not sure you need an Applicative[RecordSchema] for this (but I might be wrong), what is certain though is that you'll need an Applicative[Gen].

If you have written some code already, why not pushing a WIP PR (or pointing me to the corresponding branch on your own fork) so that I can take a look?

jkobejs commented 6 years ago

Sure, I'll push it later today.