haskell-graphql / graphql-api

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

Implement type-safe, tagged unions for graphql Unions. #63

Closed teh closed 7 years ago

teh commented 7 years ago

There's one last really important decision, and that's whether to make the union handlers themselves monadic. They are not at the moment.

My intuition says yes, people will sometimes need to run e.g IO actions before deciding which branch of a union to return, but I'm also slightly unhappy about the proliferation of pure or return.

If this all becomes a bit much we always have the option of introducing a PureField that cannot run any actions, and just takes a value?

teh commented 7 years ago

After writing a bit more test code: Yea, we need the extra monadic layer. For usability I folded the pure return into the unionValue function instead of requiring an extra pure before each unionValue call. I'd be open to expose a unionValue' that's not monadic