You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I am working on #205, and I find that I have to manually add _ everywhere for adding position infomation. And we can see quite a lot repetitive code like (in Validation.hs)
-- | Get the selection set for an operation.
getSelectionSet :: Operation value -> SelectionSetByType value
getSelectionSet (Query _ _ ss) = ss
getSelectionSet (Mutation _ _ ss) = ss
However, we can simplify them with DuplicateRecordFields and NamedFieldPuns. For example, we can have the following code in Validation.hs that:
Personally, I think by that we can make code easier to write without carefully counting the number of _s, and take advantage with other language extensions of Records when developing with graphql.
The text was updated successfully, but these errors were encountered:
Very strongly in favour of this. If I remember rightly, when we wrote this, @teh and I disagreed about whether we should prefer pattern matching (as described above) or field accessor functions. We only latched on to NamedFieldPuns later on in the piece.
Recently I am working on #205, and I find that I have to manually add
_
everywhere for adding position infomation. And we can see quite a lot repetitive code like (in Validation.hs)However, we can simplify them with
DuplicateRecordFields
andNamedFieldPuns
. For example, we can have the following code inValidation.hs
that:Furthermore, with
{-# NamedFieldPuns #-}
, we can simplify some other code fromto
Personally, I think by that we can make code easier to write without carefully counting the number of
_
s, and take advantage with other language extensions of Records when developing with graphql.The text was updated successfully, but these errors were encountered: