| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Aeson.DeriveUtils
Description
Create more idiomatic JSON/YAML representations of lens-enabled or plain
record types using deriveJSON.
data Foobar =
Foobar
{ _foobarSnickerSnack :: Int
, _foobarTumTumTree :: String
}
$(deriveLensJSON ''Foobar)
foobar = Foobar 23 "Hello, world!"
...encodes to:
{"snicker-snack":23,"tum-tum-tree":"Hello, world!"}
- deriveLensJSON :: Name -> Q [Dec]
- deriveLensJSON' :: Char -> Name -> Q [Dec]
- lensJSONOptions :: Options
- lensJSONOptions' :: Char -> Options
- ctorToDashedIdentifier :: Char -> [Char] -> [Char]
- recordToDashedIdentifier :: Char -> [Char] -> [Char]
- camelToDashed :: Char -> [Char] -> [Char]
- stripRecordPrefix :: [Char] -> [Char]
Documentation
deriveLensJSON :: Name -> Q [Dec] Source
A drop-in replacement for deriveJSON with options suitable for
record fields designed for makeLenses.
Constructor names are converted to lowercase-with-dashes; for field names,
a leading underscore and the record prefix is stripped off, and then the
same conversion to lowercase-with-dashes is performed.
deriveLensJSON' :: Char -> Name -> Q [Dec] Source
Same as deriveLensJSON, but allows for different separator characters
than - (the typical alternative choice being _).
lensJSONOptions :: Options Source
Options for deriveJSON as used by deriveLensJSON. Use this with
deriveJSON to get more control over deriving.
lensJSONOptions' :: Char -> Options Source
Options for deriveJSON as used by deriveLensJSON'. Use this with
deriveJSON to get more control over deriving.
ctorToDashedIdentifier :: Char -> [Char] -> [Char] Source
Build a dashed name from a record constructor name, e.g. FoobarBaz ->
foobar-baz.
recordToDashedIdentifier :: Char -> [Char] -> [Char] Source
Build a dashed name from a record field name, e.g. _foobarBazQuux ->
baz-quux.
camelToDashed :: Char -> [Char] -> [Char] Source
Helper that converts a camel-cased (somethingLikeThis) or pascal-cased
(SomethingLikeThis) into all-lowercase with separators, e.g.
something-like-this.
stripRecordPrefix :: [Char] -> [Char] Source
Strip record prefixes off a typical record field identifier. The prefix is assumed to be everything up to the first uppercase character in the identifier.