We have been using OverloadedRecordDot
at work and I really like it. Persistent has this feature where it will derive HasField
instances for each of the field names. I.e.
BankAccount
accountNumber String
Allows you to write bankAccount.accountNumber
instead of bankAccount.bankAccountAccountNumber
. I want this for all of my data types! Check out
derive-has-field: Derive HasField instances with Template Haskell and the source code GitHub - chiroptical/derive-has-field
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
import DeriveHasField
data BankAccount =
BankAccount
{ bankAccountAccountNumber :: String
}
deriveHasFieldWith (dropPrefix "bankAccount") ''BankAccount
Hope you enjoy!