language-avro

Language definition and parser for AVRO files. https://github.com/kutyel/avro-parser-haskell#readme

Version on this page:0.1.0.0
LTS Haskell 15.1:0.1.0.0
Stackage Nightly 2020-02-26:0.1.1.0
Latest on Hackage:0.1.1.0

See all snapshots language-avro appears in

Apache-2.0 licensed by Flavio Corpa

Module documentation for 0.1.0.0

This version can be pinned in stack with:language-avro-0.1.0.0@sha256:024dba39d3650d9fa92464e9ce1abc7e888f5ca0863958ae4aa1ab5d77fb1208,1337

avro-parser-haskell

Actions Status Hackage ormolu

Language definition and parser for AVRO (.avdl) files.

Example

#! /usr/bin/env runhaskell

module Main where

import Language.Avro.Parser (readWithImports)

main :: IO ()
main = readWithImports "test" "PeopleService.avdl"
-- λ>
-- Right
--   (Protocol {
--     ns = Just (Namespace ["example","seed","server","protocol","avro"]),
--     pname = "PeopleService", imports = [IdlImport "People.avdl"],
--     types = [
--       Record {
--         name = "Person",
--         aliases = [],
--         doc = Nothing,
--         order = Nothing,
--         fields = [
--           Field {
--             fldName = "name",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = String,
--             fldDefault = Nothing
--           },
--           Field {
--             fldName = "age",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = Int,
--             fldDefault = Nothing
--           }
--         ]
--       },
--       Record {
--         name = "NotFoundError",
--         aliases = [],
--         doc = Nothing,
--         order = Nothing,
--         fields = [
--           Field {
--             fldName = "message",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = String,
--             fldDefault = Nothing
--           }
--         ]
--       },
--       Record {
--         name = "DuplicatedPersonError",
--         aliases = [],
--         doc = Nothing,
--         order = Nothing,
--         fields = [
--           Field {
--             fldName = "message",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = String,
--             fldDefault = Nothing
--           }
--         ]
--       },
--       Record {
--         name = "PeopleRequest",
--         aliases = [],
--         doc = Nothing,
--         order = Nothing,
--         fields = [
--           Field {
--             fldName = "name",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = String,
--             fldDefault = Nothing
--           }
--         ]
--       },
--       Record {
--         name = "PeopleResponse",
--         aliases = [],
--         doc = Nothing,
--         order = Nothing,
--         fields = [
--           Field {
--             fldName = "result",
--             fldAliases = [],
--             fldDoc = Nothing,
--             fldOrder = Nothing,
--             fldType = Union {options = [NamedType "Person",NamedType "NotFoundError",NamedType "DuplicatedPersonError"]},
--             fldDefault = Nothing
--           }
--         ]
--       }
--     ],
--     messages = [
--       Method {
--         mname = "getPerson",
--         args = [Argument {atype = NamedType "example.seed.server.protocol.avro.PeopleRequest", aname = "request"}],
--         result = NamedType "example.seed.server.protocol.avro.PeopleResponse",
--         throws = Null,
--         oneway = False
--       }
--     ]
--   })

⚠️ Warning: readWithImports only works right now if the import type is "idl"!