Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/higherkindness/avro-parser-haskell
Language definition and parser for AVRO (.avdl) files.
https://github.com/higherkindness/avro-parser-haskell
avro avro-data avro-format avro-idl-files avro-schemas haskell haskell-parser parser
Last synced: about 10 hours ago
JSON representation
Language definition and parser for AVRO (.avdl) files.
- Host: GitHub
- URL: https://github.com/higherkindness/avro-parser-haskell
- Owner: higherkindness
- License: apache-2.0
- Created: 2020-01-16T12:45:03.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T17:24:57.000Z (almost 3 years ago)
- Last Synced: 2024-05-01T13:13:57.826Z (6 months ago)
- Topics: avro, avro-data, avro-format, avro-idl-files, avro-schemas, haskell, haskell-parser, parser
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/language-avro
- Size: 80.1 KB
- Stars: 16
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# avro-parser-haskell
[![Actions Status](https://github.com/higherkindness/avro-parser-haskell/workflows/Haskell%20CI/badge.svg)](https://github.com/higherkindness/avro-parser-haskell/actions)
[![Hackage](https://img.shields.io/hackage/v/language-avro.svg?logo=haskell)](https://hackage.haskell.org/package/language-avro)
[![Stackage Nightly](http://stackage.org/package/language-avro/badge/nightly)](http://stackage.org/nightly/package/language-avro)
[![Stackage LTS](http://stackage.org/package/language-avro/badge/lts)](http://stackage.org/lts/package/language-avro)
![Hackage-Deps](https://img.shields.io/hackage-deps/v/language-avro?style=flat)
[![ormolu](https://img.shields.io/badge/styled%20with-ormolu-blueviolet)](https://github.com/tweag/ormolu)Language definition and parser for AVRO (`.avdl`) files.
## Example
```haskell
#!/usr/bin/env stack
-- stack --resolver lts-18.19 script --package language-avro,pretty-simplemodule Main where
import Language.Avro.Parser (readWithImports)
import Text.Pretty.Simple (pPrint)main :: IO ()
main =
readWithImports "test" "PeopleService.avdl"
>>= either putStrLn pPrint
-- λ>
-- 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 { logicalTypeS = Nothing }
-- , fldDefault = Nothing
-- }
-- , Field
-- { fldName = "age"
-- , fldAliases = []
-- , fldDoc = Nothing
-- , fldOrder = Nothing
-- , fldType = Int { logicalTypeI = Nothing }
-- , fldDefault = Nothing
-- }
-- ]
-- }
-- , Record
-- { name = "NotFoundError"
-- , aliases = []
-- , doc = Nothing
-- , order = Nothing
-- , fields =
-- [ Field
-- { fldName = "message"
-- , fldAliases = []
-- , fldDoc = Nothing
-- , fldOrder = Nothing
-- , fldType = String { logicalTypeS = Nothing }
-- , fldDefault = Nothing
-- }
-- ]
-- }
-- , Record
-- { name = "DuplicatedPersonError"
-- , aliases = []
-- , doc = Nothing
-- , order = Nothing
-- , fields =
-- [ Field
-- { fldName = "message"
-- , fldAliases = []
-- , fldDoc = Nothing
-- , fldOrder = Nothing
-- , fldType = String { logicalTypeS = Nothing }
-- , fldDefault = Nothing
-- }
-- ]
-- }
-- , Record
-- { name = "PeopleRequest"
-- , aliases = []
-- , doc = Nothing
-- , order = Nothing
-- , fields =
-- [ Field
-- { fldName = "name"
-- , fldAliases = []
-- , fldDoc = Nothing
-- , fldOrder = Nothing
-- , fldType = String { logicalTypeS = Nothing }
-- , 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"`!