Open zhujinxuan opened 6 years ago
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.
I can't even remember that discussion but it does seem like a sensible change!
@teh , @jml Great. I will do that change after #205 is finished.
Recently I am working on https://github.com/haskell-graphql/graphql-api/pull/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.