language-avro
Language definition and parser for AVRO files.
https://github.com/kutyel/avro-parser-haskell#readme
Version on this page: | 0.1.3.1 |
LTS Haskell 22.39: | 0.1.4.0 |
Stackage Nightly 2024-10-31: | 0.1.4.0 |
Latest on Hackage: | 0.1.4.0 |
Apache-2.0 licensed by Flavio Corpa
Maintained by [email protected]
This version can be pinned in stack with:
language-avro-0.1.3.1@sha256:fd63884752e4c1a64b4f11998c7bbc60ec1d81cdc951f75eb4cf0d32b2936fce,1313
Module documentation for 0.1.3.1
- Language
- Language.Avro
Depends on 8 packages(full list with versions):
avro-parser-haskell
Language definition and parser for AVRO (.avdl
) files.
Example
#!/usr/bin/env stack
-- stack --resolver lts-15.0 script --package language-avro,megaparsec,pretty-simple
module Main where
import Language.Avro.Parser (readWithImports)
import Text.Megaparsec.Error (ShowErrorComponent (..), errorBundlePretty)
import Text.Pretty.Simple (pPrint)
instance ShowErrorComponent Char where
showErrorComponent = show
main :: IO ()
main =
readWithImports "test" "PeopleService.avdl"
>>= either (putStrLn . errorBundlePretty) 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"
!