by-other-names: Give aliases to record fields.

[ bsd3, data, library ] [ Propose Tags ]

Give aliases to record fields.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.2.0.0, 1.2.0.1, 1.2.1.0, 1.2.2.0, 1.2.3.0
Change log CHANGELOG.md
Dependencies aeson (>=2.1.0.0), base (>=4.10.0.0 && <5), indexed-traversable (>=0.1.2), template-haskell (>=2.16.0.0), text (>=1.2.3.0) [details]
License BSD-3-Clause
Author Daniel Diaz
Maintainer diaz_carrete@yahoo.com
Category Data
Source repo head: git clone https://github.com/danidiaz/by-other-names.git
Uploaded by DanielDiazCarrete at 2022-12-05T10:02:12Z
Distributions NixOS:1.2.3.0
Downloads 104 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-12-05 [all 1 reports]

Readme for by-other-names-1.2.3.0

[back to package description]

by-other-names

Give aliases to record fields.

When generically deriving aeson's `FromJSON` and `ToJSON` instances, field names are used as the keys for the serialized JSON. If you don't want that, another option is to write the instances manually. Problem is, you have to repeat the field names once for FromJSON and once for ToJSON.

I wanted an intermediate solution similar to what is provided by Go's struct tags: associate aliases with each field and use those aliases when serializing/deserializing. There can be different sets of aliases for different contexts (json, orm...). In this library, each of those possible contexts is called a "rubric".

How to depend on this library?

build-depends:
  by-other-names ^>= 1.2.3.0