Description
Derive HasField instances with Template Haskell.
Description
A Template Haskell function to derive HasField instances to utilize OverloadedRecordDot more effectively.
README.md
Derive HasField instances
The OverloadedRecordDot
syntax is surprisingly nice. I really enjoy writing code with this extension and I was originally hesistant.
Persistent has a really nice feature where it will automatically remove prefixes from models. Given a model like,
BankAccount
accountNumber String
You would normally reference this field as bankAccountAccountNumber
. However, with overloaded record dot you can write bankAccount.accountNumber
which is much nicer.
At work, I really wanted this for every record. With this library, I can write,
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
import DeriveHasField
data BankAccount =
BankAccount
{ bankAccountAccountNumber :: String
}
deriveHasFieldWith (dropPrefix "bankAccount") ''BankAccount