@hackage derive-has-field0.0.1.0
Derive HasField instances with Template Haskell
Categories
License
MIT
Maintainer
chiroptical@gmail.com
Links
Versions
Installation
Dependencies (3)
- base >=4.7 && <5
- template-haskell >=2.5 && <2.20
- th-abstraction >0.4 && <0.7 Show all…
Dependents (0)
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