tyro: Type derived JSON parsing using Aeson

[ bsd3, json, library, text, web ] [ Propose Tags ] [ Report a vulnerability ]

A library for deriving JSON parsers (using Aeson) by indicating JSON structure at the type level.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.1.0, 0.1.1.1, 0.2.0.0, 0.3.0.0
Dependencies aeson, base (>=4.9 && <5), protolude (>=0.1.6 && <0.2), singletons, text [details]
License BSD-3-Clause
Copyright 2017 Richard Lupton
Author Richard Lupton
Maintainer example@example.com
Category Text, Web, JSON
Home page https://github.com/rlupton20/tyro#readme
Source repo head: git clone https://github.com/rlupton20/tyro
Uploaded by rlupton20 at 2017-04-01T19:11:36Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2671 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-04-01 [all 1 reports]

Readme for tyro-0.1.1.1

[back to package description]

tyro

tyro is a dependently type JSON parsing library, that provides a quick way to create JSON parsers by deriving them from a type level description of the position of the value to be obtained.

Example

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}

import Data.Tyro
import Data.Aeson (decode)
import Data.Text (Text)

json = "{\"key1\":[{\"key2\":41},{\"key2\":42}]}" :: Text

-- Extract [41, 42] inside the Tyro types
parsed = decode json :: Maybe ("key1" |>| List ("key2" |>| Parse Integer))

-- We can dispose of the types using unwrap
values :: Maybe [Integer]
values = fmap unwrap parsed