sannsyn / json-encoder Goto Github PK
View Code? Open in Web Editor NEWA single-pass JSON encoder with a declarative DSL
Home Page: http://hackage.haskell.org/package/json-encoder
License: MIT License
A single-pass JSON encoder with a declarative DSL
Home Page: http://hackage.haskell.org/package/json-encoder
License: MIT License
Hi, I just stumbled upon this library and tried it out. First time using Decidable
and Divisible
and they seem rather elegant. However, I found the code rather hard to write without infix operators similar to <*>
and <|>
. Moreover, I had to manually turn my ADT into a "canonical" form, using Either
and (,)
.
For example,
data Foo
= One Text
| Two Text Text
| Three Text Text Text
-- it would be nice to derive this with Generics and TH
gfoo :: Foo -> Either Text (Either (Text, Text) (Text, (Text, Text)))
gfoo = ...
fooValue :: Value Foo
fooValue = contramap gfoo $
string
<||> string <//> string
<||> string <//> string <//> string
infixr 4 <||>
(<||>) = chosen
infixr 5 <//>
(<//>) = divided
Anyways, I guess my question is what is the recommended way of writing Value
s? It seems wrong to include operators here that aren't defined in contramap
- and I assume they aren't defined in contramap
for a good reason. But, I couldn't figure out a way to write readable code without them.
Thanks!
Mitchell
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.