| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Record.TH
Synopsis
- lr :: QuasiQuoter
- data Options = Options {}
- defaultLazyOptions :: Options
- defaultStrictOptions :: Options
- defaultPureScript :: Options
- largeRecord :: Options -> Q [Dec] -> Q [Dec]
Documentation
lr :: QuasiQuoter Source #
Construct or match on large-records-style records
Example construction usage:
inOrder :: R Bool
inOrder = [lr| MkR { x = 1234, y = [True] } |]or:
constructorApp :: R Bool constructorApp = [lr| MkR |] 1234 [True]
Example matching usage:
projectOne :: T Bool -> Int
projectOne [lr| MkT { x = a } |] = aTweak the output of the generator
In the explanations of the various options below, we will use the following record as our running example:
data T a b = MkT {
tWord :: Word
, tBool :: Bool
, tChar :: Char
, tA :: a
, tListB :: [b]
}
deriving (Eq, Show)Constructors
| Options | |
Fields
| |
defaultPureScript :: Options Source #
Default options for "Purescript style" records
That is:
- All fields are strict
- We do not generate field accessors: fields must be accessed and updated
through the
HasFieldinstances (e.g.,record-dot-preprocessorsyntax).
We do not introduce a pattern synonym by default:
- Introducing a pattern synonym reintroduces code that is quadratic in size.
- Perhaps more importantly, it would make it impossible to define two records with the same field names in a single module, as the field accessors (unnecessarily but currently unavoidably) introduced by the pattern synonym would clash.
NOTE: The record-dot-preprocessor enables DuplicateRecordFields by
default. Since the records that we produce are not visible to ghc,
large-records is not compatible with DRF-style overloading. However, as
long as all overloading is resolved through HasField instead (which is
what record-dot-preprocessor encourages anyway), all is fine.