Skip to content

gregwebs/aeson-applicative

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

make To/From JSON instances from an applicative description

data R = R { a :: Text, b :: Int32 } deriving (Typeable)

rJsonInfo :: JsonInfo R
rJsonInfo = R
        <$> "a" @: a
        <*> 'b  @: b

instance ToJSON R where
  toJSON = jiToJSON rJsonInfo
instance FromJSON R where
  parseJSON = jiParseJSON rJsonInfo

This is a simple application of a bi-directional applicative DSL concept.

It has the advantage of not requiring Template Haskell. However, the resulting code will certainly be less efficient. A faster implementation would be to use Template Haskell to generate efficient code.

About

define To/From JSON instances from one applicative definition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published