avro-0.4.7.0: Avro serialization support for Haskell

Safe HaskellNone
LanguageHaskell2010

Data.Avro.Schema

Contents

Description

Avro Schemas, represented here as values of type Schema, describe the serialization and de-serialization of values.

In Avro schemas are compose-able such that encoding data under a schema and decoding with a variant, such as newer or older version of the original schema, can be accomplished by using the Deconflict module.

Synopsis

Schema description types

data Schema Source #

N.B. It is possible to create a Haskell value (of Schema type) that is not a valid Avro schema by violating one of the above or one of the conditions called out in validateSchema.

Bundled Patterns

pattern Int' :: Schema 
pattern Long' :: Schema 
pattern Bytes' :: Schema 
pattern String' :: Schema 
Instances
Eq Schema Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(==) :: Schema -> Schema -> Bool #

(/=) :: Schema -> Schema -> Bool #

Ord Schema Source # 
Instance details

Defined in Data.Avro.Schema

Show Schema Source # 
Instance details

Defined in Data.Avro.Schema

Generic Schema Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep Schema :: Type -> Type #

Methods

from :: Schema -> Rep Schema x #

to :: Rep Schema x -> Schema #

Lift Schema Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: Schema -> Q Exp #

ToJSON Schema Source # 
Instance details

Defined in Data.Avro.Schema

FromJSON Schema Source # 
Instance details

Defined in Data.Avro.Schema

NFData Schema Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: Schema -> () #

ToJSON (Value Schema) Source # 
Instance details

Defined in Data.Avro.Schema

EncodeAvro (Value Schema) Source # 
Instance details

Defined in Data.Avro.Encode

Methods

avro :: Value Schema -> AvroM Source #

type Rep Schema Source # 
Instance details

Defined in Data.Avro.Schema

type Rep Schema = D1 (MetaData "Schema" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (((C1 (MetaCons "Null" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Boolean" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Int" PrefixI True) (S1 (MetaSel (Just "logicalTypeI") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe LogicalTypeInt))))) :+: ((C1 (MetaCons "Long" PrefixI True) (S1 (MetaSel (Just "logicalTypeL") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe LogicalTypeLong))) :+: C1 (MetaCons "Float" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Double" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Bytes" PrefixI True) (S1 (MetaSel (Just "logicalTypeB") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe LogicalTypeBytes)))))) :+: (((C1 (MetaCons "String" PrefixI True) (S1 (MetaSel (Just "logicalTypeS") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe LogicalTypeString))) :+: C1 (MetaCons "Array" PrefixI True) (S1 (MetaSel (Just "item") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Schema))) :+: (C1 (MetaCons "Map" PrefixI True) (S1 (MetaSel (Just "values") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Schema)) :+: C1 (MetaCons "NamedType" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TypeName)))) :+: ((C1 (MetaCons "Record" PrefixI True) ((S1 (MetaSel (Just "name") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TypeName) :*: S1 (MetaSel (Just "aliases") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [TypeName])) :*: (S1 (MetaSel (Just "doc") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text)) :*: (S1 (MetaSel (Just "order") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Order)) :*: S1 (MetaSel (Just "fields") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Field])))) :+: C1 (MetaCons "Enum" PrefixI True) ((S1 (MetaSel (Just "name") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TypeName) :*: S1 (MetaSel (Just "aliases") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [TypeName])) :*: (S1 (MetaSel (Just "doc") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text)) :*: S1 (MetaSel (Just "symbols") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector Text))))) :+: (C1 (MetaCons "Union" PrefixI True) (S1 (MetaSel (Just "options") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector Schema))) :+: C1 (MetaCons "Fixed" PrefixI True) ((S1 (MetaSel (Just "name") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TypeName) :*: S1 (MetaSel (Just "aliases") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [TypeName])) :*: (S1 (MetaSel (Just "size") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int) :*: S1 (MetaSel (Just "logicalTypeF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe LogicalTypeFixed))))))))

type Type = Schema Source #

Deprecated: Use Schema instead

data Field Source #

Instances
Eq Field Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(==) :: Field -> Field -> Bool #

(/=) :: Field -> Field -> Bool #

Ord Field Source # 
Instance details

Defined in Data.Avro.Schema

Methods

compare :: Field -> Field -> Ordering #

(<) :: Field -> Field -> Bool #

(<=) :: Field -> Field -> Bool #

(>) :: Field -> Field -> Bool #

(>=) :: Field -> Field -> Bool #

max :: Field -> Field -> Field #

min :: Field -> Field -> Field #

Show Field Source # 
Instance details

Defined in Data.Avro.Schema

Methods

showsPrec :: Int -> Field -> ShowS #

show :: Field -> String #

showList :: [Field] -> ShowS #

Generic Field Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep Field :: Type -> Type #

Methods

from :: Field -> Rep Field x #

to :: Rep Field x -> Field #

Lift Field Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: Field -> Q Exp #

NFData Field Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: Field -> () #

type Rep Field Source # 
Instance details

Defined in Data.Avro.Schema

data Order Source #

Constructors

Ascending 
Descending 
Ignore 
Instances
Eq Order Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(==) :: Order -> Order -> Bool #

(/=) :: Order -> Order -> Bool #

Ord Order Source # 
Instance details

Defined in Data.Avro.Schema

Methods

compare :: Order -> Order -> Ordering #

(<) :: Order -> Order -> Bool #

(<=) :: Order -> Order -> Bool #

(>) :: Order -> Order -> Bool #

(>=) :: Order -> Order -> Bool #

max :: Order -> Order -> Order #

min :: Order -> Order -> Order #

Show Order Source # 
Instance details

Defined in Data.Avro.Schema

Methods

showsPrec :: Int -> Order -> ShowS #

show :: Order -> String #

showList :: [Order] -> ShowS #

Generic Order Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep Order :: Type -> Type #

Methods

from :: Order -> Rep Order x #

to :: Rep Order x -> Order #

Lift Order Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: Order -> Q Exp #

ToJSON Order Source # 
Instance details

Defined in Data.Avro.Schema

FromJSON Order Source # 
Instance details

Defined in Data.Avro.Schema

NFData Order Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: Order -> () #

type Rep Order Source # 
Instance details

Defined in Data.Avro.Schema

type Rep Order = D1 (MetaData "Order" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "Ascending" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Descending" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Ignore" PrefixI False) (U1 :: Type -> Type)))

data TypeName Source #

A named type in Avro has a name and, optionally, a namespace.

A name is a string that starts with an ASCII letter or underscore followed by letters, underscores and digits:

name ::= [A-Za-z_][A-Za-z0-9_]*

Examples include "_foo7", Bar_ and "x".

A namespace is a sequence of names with the same lexical structure. When written as a string, the components of a namespace are separated with dots ("com.example").

TypeName represents a fullname—a name combined with a namespace. These are written and parsed as dot-separated strings. The TypeName TN Foo ["com", "example"] is rendered as "com.example.Foo".

Fullnames have to be globally unique inside an Avro schema.

A namespace of [] or [""] is the "null namespace". In avro an explicitly null-namespaced identifier is written as ".Foo"

Constructors

TN 

Fields

Instances
Eq TypeName Source # 
Instance details

Defined in Data.Avro.Schema

Ord TypeName Source # 
Instance details

Defined in Data.Avro.Schema

Show TypeName Source #

Show the TypeName as a string literal compatible with its IsString instance.

Instance details

Defined in Data.Avro.Schema

IsString TypeName Source #

This lets us write TypeNames as string literals in a fully qualified style. "com.example.foo" is the name "foo" with the namespace "com.example"; "foo" is the name "foo" with no namespace.

Instance details

Defined in Data.Avro.Schema

Generic TypeName Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep TypeName :: Type -> Type #

Methods

from :: TypeName -> Rep TypeName x #

to :: Rep TypeName x -> TypeName #

Lift TypeName Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: TypeName -> Q Exp #

Hashable TypeName Source # 
Instance details

Defined in Data.Avro.Schema

Methods

hashWithSalt :: Int -> TypeName -> Int #

hash :: TypeName -> Int #

NFData TypeName Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: TypeName -> () #

type Rep TypeName Source # 
Instance details

Defined in Data.Avro.Schema

type Rep TypeName = D1 (MetaData "TypeName" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "TN" PrefixI True) (S1 (MetaSel (Just "baseName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text) :*: S1 (MetaSel (Just "namespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text])))

data Decimal Source #

Constructors

Decimal 
Instances
Eq Decimal Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(==) :: Decimal -> Decimal -> Bool #

(/=) :: Decimal -> Decimal -> Bool #

Ord Decimal Source # 
Instance details

Defined in Data.Avro.Schema

Show Decimal Source # 
Instance details

Defined in Data.Avro.Schema

Generic Decimal Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep Decimal :: Type -> Type #

Methods

from :: Decimal -> Rep Decimal x #

to :: Rep Decimal x -> Decimal #

Lift Decimal Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: Decimal -> Q Exp #

NFData Decimal Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: Decimal -> () #

type Rep Decimal Source # 
Instance details

Defined in Data.Avro.Schema

type Rep Decimal = D1 (MetaData "Decimal" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "Decimal" PrefixI True) (S1 (MetaSel (Just "precision") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer) :*: S1 (MetaSel (Just "scale") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer)))

newtype LogicalTypeBytes Source #

Constructors

DecimalB Decimal 
Instances
Eq LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

Ord LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

Show LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

Generic LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep LogicalTypeBytes :: Type -> Type #

Lift LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: LogicalTypeBytes -> Q Exp #

NFData LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: LogicalTypeBytes -> () #

type Rep LogicalTypeBytes Source # 
Instance details

Defined in Data.Avro.Schema

type Rep LogicalTypeBytes = D1 (MetaData "LogicalTypeBytes" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" True) (C1 (MetaCons "DecimalB" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Decimal)))

data LogicalTypeFixed Source #

Constructors

DecimalF Decimal 
Duration 
Instances
Eq LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

Ord LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

Show LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

Generic LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep LogicalTypeFixed :: Type -> Type #

Lift LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: LogicalTypeFixed -> Q Exp #

NFData LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: LogicalTypeFixed -> () #

type Rep LogicalTypeFixed Source # 
Instance details

Defined in Data.Avro.Schema

type Rep LogicalTypeFixed = D1 (MetaData "LogicalTypeFixed" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "DecimalF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Decimal)) :+: C1 (MetaCons "Duration" PrefixI False) (U1 :: Type -> Type))

data LogicalTypeInt Source #

Instances
Eq LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

Ord LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

Show LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

Generic LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep LogicalTypeInt :: Type -> Type #

Lift LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: LogicalTypeInt -> Q Exp #

NFData LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: LogicalTypeInt -> () #

type Rep LogicalTypeInt Source # 
Instance details

Defined in Data.Avro.Schema

type Rep LogicalTypeInt = D1 (MetaData "LogicalTypeInt" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "DecimalI" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Decimal)) :+: (C1 (MetaCons "Date" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TimeMillis" PrefixI False) (U1 :: Type -> Type)))

data LogicalTypeLong Source #

Instances
Eq LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

Ord LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

Show LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

Generic LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep LogicalTypeLong :: Type -> Type #

Lift LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

Methods

lift :: LogicalTypeLong -> Q Exp #

NFData LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: LogicalTypeLong -> () #

type Rep LogicalTypeLong Source # 
Instance details

Defined in Data.Avro.Schema

type Rep LogicalTypeLong = D1 (MetaData "LogicalTypeLong" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) ((C1 (MetaCons "DecimalL" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Decimal)) :+: C1 (MetaCons "TimeMicros" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "TimestampMillis" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TimestampMicros" PrefixI False) (U1 :: Type -> Type)))

data LogicalTypeString Source #

Constructors

UUID 
Instances
Eq LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

Ord LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

Show LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

Generic LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

Associated Types

type Rep LogicalTypeString :: Type -> Type #

Lift LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Deriving.Lift

NFData LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

Methods

rnf :: LogicalTypeString -> () #

type Rep LogicalTypeString Source # 
Instance details

Defined in Data.Avro.Schema

type Rep LogicalTypeString = D1 (MetaData "LogicalTypeString" "Data.Avro.Schema" "avro-0.4.7.0-Bfa0q2x5HB9FRvrjrQk9PL" False) (C1 (MetaCons "UUID" PrefixI False) (U1 :: Type -> Type))

renderFullname :: TypeName -> Text Source #

Render a fullname as a dot separated string.

> renderFullname (TN Foo ["com", "example"])
"com.example.Foo"
> renderFullname (TN Foo [])
".Foo"

parseFullname :: Text -> TypeName Source #

Parses a fullname into a TypeName, assuming the string representation is valid.

> parseFullname "com.example.Foo"
TN { baseName = Foo, components = ["com", "example"] }

mkEnum Source #

Arguments

:: TypeName

The name of the enum (includes namespace).

-> [TypeName]

Aliases for the enum (if any).

-> Maybe Text

Optional documentation for the enum.

-> [Text]

The symbols of the enum.

-> Schema 

Build an Schema value from its components.

mkUnion :: NonEmpty Schema -> Schema Source #

mkUnion subTypes Defines a union of the provided subTypes. N.B. it is invalid Avro to include another union or to have more than one of the same type as a direct member of the union. No check is done for this condition!

validateSchema :: Schema -> Parser () Source #

Placeholder NO-OP function!

Validates a schema to ensure:

  • All types are defined
  • Unions do not directly contain other unions
  • Unions are not ambiguous (may not contain more than one schema with the same type except for named types of record, fixed and enum)
  • Default values for unions can be cast as the type indicated by the first structure.
  • Default values can be cast/de-serialize correctly.
  • Named types are resolvable

Lower level utilities

typeName :: Schema -> Text Source #

Get the name of the type. In the case of unions, get the name of the first value in the union schema.

buildTypeEnvironment Source #

Arguments

:: Applicative m 
=> (TypeName -> m Schema)

Callback to handle type names not in the schema.

-> Schema

The schema that we're generating a lookup function for.

-> TypeName -> m Schema 

buildTypeEnvironment schema builds a function mapping type names to the types declared in the traversed schema.

This mapping includes both the base type names and any aliases they have. Aliases and normal names are not differentiated in any way.

extractBindings :: Schema -> HashMap TypeName Schema Source #

extractBindings schema traverses a schema and builds a map of all declared types.

Types declared implicitly in record field definitions are also included. No distinction is made between aliases and normal names.

data Result a Source #

Constructors

Success a 
Error String 
Instances
Monad Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(>>=) :: Result a -> (a -> Result b) -> Result b #

(>>) :: Result a -> Result b -> Result b #

return :: a -> Result a #

fail :: String -> Result a #

Functor Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

MonadFail Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

fail :: String -> Result a #

Applicative Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

pure :: a -> Result a #

(<*>) :: Result (a -> b) -> Result a -> Result b #

liftA2 :: (a -> b -> c) -> Result a -> Result b -> Result c #

(*>) :: Result a -> Result b -> Result b #

(<*) :: Result a -> Result b -> Result a #

Foldable Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

fold :: Monoid m => Result m -> m #

foldMap :: Monoid m => (a -> m) -> Result a -> m #

foldr :: (a -> b -> b) -> b -> Result a -> b #

foldr' :: (a -> b -> b) -> b -> Result a -> b #

foldl :: (b -> a -> b) -> b -> Result a -> b #

foldl' :: (b -> a -> b) -> b -> Result a -> b #

foldr1 :: (a -> a -> a) -> Result a -> a #

foldl1 :: (a -> a -> a) -> Result a -> a #

toList :: Result a -> [a] #

null :: Result a -> Bool #

length :: Result a -> Int #

elem :: Eq a => a -> Result a -> Bool #

maximum :: Ord a => Result a -> a #

minimum :: Ord a => Result a -> a #

sum :: Num a => Result a -> a #

product :: Num a => Result a -> a #

Traversable Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

traverse :: Applicative f => (a -> f b) -> Result a -> f (Result b) #

sequenceA :: Applicative f => Result (f a) -> f (Result a) #

mapM :: Monad m => (a -> m b) -> Result a -> m (Result b) #

sequence :: Monad m => Result (m a) -> m (Result a) #

Alternative Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

empty :: Result a #

(<|>) :: Result a -> Result a -> Result a #

some :: Result a -> Result [a] #

many :: Result a -> Result [a] #

MonadPlus Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

mzero :: Result a #

mplus :: Result a -> Result a -> Result a #

MonadError String Result Source # 
Instance details

Defined in Data.Avro.Schema

Methods

throwError :: String -> Result a #

catchError :: Result a -> (String -> Result a) -> Result a #

Eq a => Eq (Result a) Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(==) :: Result a -> Result a -> Bool #

(/=) :: Result a -> Result a -> Bool #

Ord a => Ord (Result a) Source # 
Instance details

Defined in Data.Avro.Schema

Methods

compare :: Result a -> Result a -> Ordering #

(<) :: Result a -> Result a -> Bool #

(<=) :: Result a -> Result a -> Bool #

(>) :: Result a -> Result a -> Bool #

(>=) :: Result a -> Result a -> Bool #

max :: Result a -> Result a -> Result a #

min :: Result a -> Result a -> Result a #

Show a => Show (Result a) Source # 
Instance details

Defined in Data.Avro.Schema

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

Semigroup (Result a) Source # 
Instance details

Defined in Data.Avro.Schema

Methods

(<>) :: Result a -> Result a -> Result a #

sconcat :: NonEmpty (Result a) -> Result a #

stimes :: Integral b => b -> Result a -> Result a #

Monoid (Result a) Source # 
Instance details

Defined in Data.Avro.Schema

Methods

mempty :: Result a #

mappend :: Result a -> Result a -> Result a #

mconcat :: [Result a] -> Result a #

badValue :: Show t => t -> String -> Result a Source #

matches :: Schema -> Schema -> Bool Source #

Checks that two schemas match. This is like equality of schemas, except NamedTypes match against other types with the same name.

This extends recursively: two records match if they have the same name, the same number of fields and the fields all match.

parseBytes :: Text -> Result ByteString Source #

Parses a string literal into a bytestring in the format expected for bytes and fixed values. Will fail if every character does not have a codepoint between 0 and 255.

serializeBytes :: ByteString -> Text Source #

Turn a ByteString into a Text that matches the format Avro expects from bytes and fixed literals in JSON. Each byte is mapped to a single Unicode codepoint between 0 and 255.

parseAvroJSON Source #

Arguments

:: (Schema -> Value -> Result (Value Schema))

How to handle unions. The way unions are formatted in JSON depends on whether we're parsing a normal Avro object or we're parsing a default declaration in a schema.

This function will only ever be passed Union schemas. It should error out if this is not the case—it represents a bug in this code.

-> (TypeName -> Maybe Schema) 
-> Schema 
-> Value 
-> Result (Value Schema) 

Parse JSON-encoded avro data.

overlay :: Schema -> Schema -> Schema Source #

Merge two schemas to produce a third. Specifically, overlay schema reference fills in NamedTypes in schema using any matching definitions from reference.

subdefinition :: Schema -> Text -> Maybe Schema Source #

Extract the named inner type definition as its own schema.