Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data DeriveOptions = DeriveOptions {
- doFieldNameBuilder :: TypeName -> Field -> Name
- defaultDeriveOptions :: DeriveOptions
- mkPrefixedFieldName :: TypeName -> Field -> Name
- mkAsIsFieldName :: TypeName -> Field -> Name
- deriveAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec]
- deriveAvroWithOptions' :: DeriveOptions -> Schema -> Q [Dec]
- deriveFromAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec]
- deriveAvro :: FilePath -> Q [Dec]
- deriveAvro' :: Schema -> Q [Dec]
- deriveFromAvro :: FilePath -> Q [Dec]
Deriving options
data DeriveOptions Source #
Derives Avro from a given schema file. Generates data types, FromAvro and ToAvro instances.
DeriveOptions | |
|
defaultDeriveOptions :: DeriveOptions Source #
Default deriving options
defaultDeriveOptions =DeriveOptions
{ doFieldNameBuilder =mkPrefixedFieldName
}
mkPrefixedFieldName :: TypeName -> Field -> Name Source #
Generates a field name that is prefixed with the type name.
For example, if the schema defines type Person
that has a field firstName
,
then the generated Haskell type will be like
Person { personFirstName :: Text }
mkAsIsFieldName :: TypeName -> Field -> Name Source #
Generates a field name that matches the field name in schema (sanitised for Haskell, so first letter is lower cased)
For example, if the schema defines type Person
that has a field firstName
,
then the generated Haskell type will be like
Person { firstName :: Text }
You may want to enable DuplicateRecordFields
if you want to use this method.
Deriving Haskell types from Avro schema
deriveAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec] Source #
deriveAvroWithOptions' :: DeriveOptions -> Schema -> Q [Dec] Source #
deriveFromAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec] Source #
Derives "read only" Avro from a given schema file. Generates data types and FromAvro.
deriveAvro :: FilePath -> Q [Dec] Source #
Same as deriveAvroWithOptions
but uses defaultDeriveOptions
deriveAvro' = deriveAvroWithOptions' defaultDeriveOptions
deriveAvro' :: Schema -> Q [Dec] Source #
Same as deriveAvroWithOptions'
but uses defaultDeriveOptions
deriveAvro' =deriveAvroWithOptions'
defaultDeriveOptions