danidiaz / by-other-names Goto Github PK
View Code? Open in Web Editor NEWGive aliases to record fields
License: BSD 3-Clause "New" or "Revised" License
Give aliases to record fields
License: BSD 3-Clause "New" or "Revised" License
Currently it's private.
Useful when defining functions for enum-like types.
Maybe call it Never
.
Could Typed Template Haskell be useful here? I don't want to generate all the instance declaration, only the implementation of aliases
.
It's not that useful after all.
Currently,
For sum types, only the "object with a single key consisting in the branch tag" style of serialization is supported.
It would be good to have a DerivingVia adapter for enum-like sum types, sum-types without any fields in their constructors. They would be encoded as JSON String
values.
This would likely require generalized versions of JSONRecord
, JSONSum
and JSONEnum
.
No sure how useful would this be. Perhaps it's enough to stick to the JSON
rubric.
They could be useful for generating schemas from types and the like.
Add also some way of demoting them, at least for sum types...
This wil couple aeson with the main library but who cares.
As needed.
The guts of the Aliases
GADT probably don't need to be exposed in the main ByOtherNames
module.
Don't just repeat the synopsis.
Use -XTypeApplications
exclusively.
Right now the "aliases" are always of the same type, for every field in a record.
But what if, instead of having a fixed type, we had a type constructor wrapping each particular field's type? Very much like sop-core's NP
type, only not anonymous.
The current Aliases a
would become a particular case: AliasesF (Const a)
.
This for example would allow us to manually specify JSON parsers for each field, without necessarily requiring FromJSON instances for all.
But perhaps this would add too much complexity.
Added in 8a2e8af.
There isn't a need to have two different functions.
Look in A story told by Type Errors for inspiration.
Here's what the GHC User Guide says about them.
It could be done, if needed. Right now we only handle C1 x U1
and C1 x (S1 y (Rec0 v))
, but we could also handle C1 x (left :*: right)
.
The fields could be serialized as a JSON array.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.