haskell-graphql / graphql-api

Write type-safe GraphQL services in Haskell
BSD 3-Clause "New" or "Revised" License
406 stars 35 forks source link

QuickCheck for Values #27

Closed jml closed 7 years ago

jml commented 7 years ago

Pretty boring (at last). Depends on #26.

Fixes #23.

Note that List is too generously typed. I can't think of a good way of encoding homogeneous lists without adding a type parameter. I think we'll have to suck that one up.

jml commented 7 years ago

Reckon I should do this for all of the arbitrary instances? I could go either way between Arbitrary and named generators. On Sun, 18 Dec 2016 at 12:06, teh notifications@github.com wrote:

@teh approved this pull request.

Arbitrary instances are good but I'm also a fan of the forAll style, i.e. instead of a single Arbirtary List we could add (untested sketch)

genValidList = (suchThat arbitrary ((List items) -> all (map itemValid items))) forAll genValidList checkThing

and remove the Arbitrary instance. That'd get around the overly generic instance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jml/graphql-api/pull/27#pullrequestreview-13462895, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHq6isCnUJmDral5x2pzZaIgtMofYrdks5rJSGagaJpZM4LQAbH .

teh commented 7 years ago

No what you have is good for now, we can add the extra forAll code as we need it.

jml commented 7 years ago

Thanks.

I thought of a way we might be able to restructure the type, at least to make sure that the "top-level" types are the same (e.g. everything is an "Object" but cannot enforce that they are the same type of object). I think that's the best we can get since this level is entirely separate from the GraphQL type system, and that's as it should be.

I'll file a ticket though, and move on with CanonicalQuery.