Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 } |] = a
Tweak 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)
Options | |
|
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
HasField
instances (e.g.,record-dot-preprocessor
syntax).
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.