-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Avro serialization support for Haskell
--   
--   Avro serialization and deserialization support for Haskell
@package avro
@version 0.4.3.0

module Data.Avro.Codec

-- | A <a>Codec</a> allows for compression/decompression of a block in an
--   Avro container according to the Avro spec.
data Codec
Codec :: ByteString -> (forall a. Decompress a) -> (ByteString -> ByteString) -> Codec

-- | The name of the codec according to the Avro spec.
[codecName] :: Codec -> ByteString

-- | Execute a <a>Get</a> over a chunk of bytes possibly decompressing the
--   chunk incrementally.
--   
--   The API is somewhat more complex than say <a>codecCompress</a> to
--   allow interleaving of decompression and binary decoding while still
--   allowing proper error handling without resorting to async exceptions.
[codecDecompress] :: Codec -> forall a. Decompress a

-- | Compresses a lazy stream of bytes.
[codecCompress] :: Codec -> ByteString -> ByteString

-- | Block decompression function for blocks of Avro.
type Decompress a = ByteString -> Get a -> Either String a

-- | <a>nullCodec</a> specifies <tt>null</tt> required by Avro spec. (see
--   <a>https://avro.apache.org/docs/1.8.1/spec.html#null)</a>
nullCodec :: Codec

-- | <a>deflateCodec</a> specifies <tt>deflate</tt> codec required by Avro
--   spec. (see
--   <a>https://avro.apache.org/docs/1.8.1/spec.html#deflate)</a>
deflateCodec :: Codec

module Data.Avro.Decode.Lazy.LazyValue
data LazyValue f
Null :: LazyValue f
Boolean :: Bool -> LazyValue f
Int :: Int32 -> LazyValue f
Long :: Int64 -> LazyValue f
Float :: Float -> LazyValue f
Double :: Double -> LazyValue f
Bytes :: ByteString -> LazyValue f
String :: Text -> LazyValue f

-- | Dynamically enforced monomorphic type.
Array :: Vector (LazyValue f) -> LazyValue f

-- | Dynamically enforced monomorphic type
Map :: HashMap Text (LazyValue f) -> LazyValue f
Record :: f -> HashMap Text (LazyValue f) -> LazyValue f

-- | Set of union options, schema for selected option, and the actual
--   value.
Union :: NonEmpty f -> f -> LazyValue f -> LazyValue f
Fixed :: f -> ByteString -> LazyValue f

-- | An enum is a set of the possible symbols (the schema) and the selected
--   symbol
Enum :: f -> Int -> Text -> LazyValue f
Error :: !String -> LazyValue f
instance GHC.Show.Show f => GHC.Show.Show (Data.Avro.Decode.Lazy.LazyValue.LazyValue f)
instance GHC.Classes.Eq f => GHC.Classes.Eq (Data.Avro.Decode.Lazy.LazyValue.LazyValue f)

module Data.Avro.Decode.Strict

module Data.Avro.Types.Value
data Value f
Null :: Value f
Boolean :: !Bool -> Value f
Int :: {-# UNPACK #-} !Int32 -> Value f
Long :: {-# UNPACK #-} !Int64 -> Value f
Float :: {-# UNPACK #-} !Float -> Value f
Double :: {-# UNPACK #-} !Double -> Value f
Bytes :: {-# UNPACK #-} !ByteString -> Value f
String :: {-# UNPACK #-} !Text -> Value f

-- | Dynamically enforced monomorphic type.
Array :: Vector (Value f) -> Value f

-- | Dynamically enforced monomorphic type
Map :: HashMap Text (Value f) -> Value f
Record :: f -> HashMap Text (Value f) -> Value f

-- | Set of union options, schema for selected option, and the actual
--   value.
Union :: NonEmpty f -> f -> Value f -> Value f
Fixed :: f -> {-# UNPACK #-} !ByteString -> Value f

-- | An enum is a set of the possible symbols (the schema) and the selected
--   symbol
Enum :: f -> {-# UNPACK #-} !Int -> Text -> Value f
instance Control.DeepSeq.NFData f => Control.DeepSeq.NFData (Data.Avro.Types.Value.Value f)
instance GHC.Generics.Generic (Data.Avro.Types.Value.Value f)
instance GHC.Show.Show f => GHC.Show.Show (Data.Avro.Types.Value.Value f)
instance GHC.Classes.Eq f => GHC.Classes.Eq (Data.Avro.Types.Value.Value f)

module Data.Avro.Types


-- | Avro <a>Schema</a>s, represented here as values of type <a>Schema</a>,
--   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
--   <a>Deconflict</a> module.
module Data.Avro.Schema

-- | An Avro schema is either * A "JSON object in the form
--   `{"type":"typeName" ...` * A "JSON string, naming a defined type"
--   (basic type w<i>o free variables</i>names) * A "JSON array,
--   representing a union"
--   
--   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 <a>validateSchema</a>.
type Schema = Type

-- | Avro types are considered either primitive (string, int, etc) or
--   complex/declared (structures, unions etc).
data Type
Null :: Type
Boolean :: Type
Int :: Type
Long :: Type
Float :: Type
Double :: Type
Bytes :: Type
String :: Type
Array :: Type -> Type
[item] :: Type -> Type
Map :: Type -> Type
[values] :: Type -> Type
NamedType :: TypeName -> Type
Record :: TypeName -> [TypeName] -> Maybe Text -> Maybe Order -> [Field] -> Type
[name] :: Type -> TypeName
[aliases] :: Type -> [TypeName]
[doc] :: Type -> Maybe Text
[order] :: Type -> Maybe Order
[fields] :: Type -> [Field]
Enum :: TypeName -> [TypeName] -> Maybe Text -> [Text] -> (Int64 -> Maybe Text) -> Type
[name] :: Type -> TypeName
[aliases] :: Type -> [TypeName]
[doc] :: Type -> Maybe Text
[symbols] :: Type -> [Text]
[symbolLookup] :: Type -> Int64 -> Maybe Text
Union :: NonEmpty Type -> (Int64 -> Maybe Type) -> Type
[options] :: Type -> NonEmpty Type
[unionLookup] :: Type -> Int64 -> Maybe Type
Fixed :: TypeName -> [TypeName] -> Int -> Type
[name] :: Type -> TypeName
[aliases] :: Type -> [TypeName]
[size] :: Type -> Int
data Field
Field :: Text -> [Text] -> Maybe Text -> Maybe Order -> Type -> Maybe (Value Type) -> Field
[fldName] :: Field -> Text
[fldAliases] :: Field -> [Text]
[fldDoc] :: Field -> Maybe Text
[fldOrder] :: Field -> Maybe Order
[fldType] :: Field -> Type
[fldDefault] :: Field -> Maybe (Value Type)
data Order
Ascending :: Order
Descending :: Order
Ignore :: Order

-- | 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:
--   
--   <pre>
--   name ::= [A-Za-z_][A-Za-z0-9_]*
--   </pre>
--   
--   Examples include <tt>"_foo7"</tt>, <tt><a>Bar_</a></tt> and
--   <tt>"x"</tt>.
--   
--   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 (<tt>"com.example"</tt>).
--   
--   <a>TypeName</a> represents a <i>fullname</i>—a name combined with a
--   namespace. These are written and parsed as dot-separated strings. The
--   <a>TypeName</a> <tt>TN <a>Foo</a> ["com", "example"]</tt> is rendered
--   as <tt>"com.example.Foo"</tt>.
--   
--   Fullnames have to be globally unique inside an Avro schema.
--   
--   A namespace of <tt>[]</tt> or <tt>[""]</tt> is the "null namespace".
--   In avro an explicitly null-namespaced identifier is written as ".Foo"
data TypeName
TN :: Text -> [Text] -> TypeName
[baseName] :: TypeName -> Text
[namespace] :: TypeName -> [Text]

-- | Render a fullname as a dot separated string.
--   
--   <pre>
--   &gt; renderFullname (TN <a>Foo</a> ["com", "example"])
--   "com.example.Foo"
--   </pre>
--   
--   <pre>
--   &gt; renderFullname (TN <a>Foo</a> [])
--   ".Foo"
--   </pre>
renderFullname :: TypeName -> Text

-- | Parses a fullname into a <a>TypeName</a>, assuming the string
--   representation is valid.
--   
--   <pre>
--   &gt; parseFullname "com.example.Foo"
--   TN { baseName = <a>Foo</a>, components = ["com", "example"] }
--   </pre>
parseFullname :: Text -> TypeName

-- | Build an <a>Type</a> value from its components.
mkEnum :: TypeName -> [TypeName] -> Maybe Text -> [Text] -> Type

-- | <tt>mkUnion subTypes</tt> 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!
mkUnion :: NonEmpty Type -> Type

-- | Placeholder NO-OP function!
--   
--   Validates a schema to ensure:
--   
--   <ul>
--   <li>All types are defined</li>
--   <li>Unions do not directly contain other unions</li>
--   <li>Unions are not ambiguous (may not contain more than one schema
--   with the same type except for named types of record, fixed and
--   enum)</li>
--   <li>Default values for unions can be cast as the type indicated by the
--   first structure.</li>
--   <li>Default values can be cast/de-serialize correctly.</li>
--   <li>Named types are resolvable</li>
--   </ul>
validateSchema :: Schema -> Parser ()

-- | Get the name of the type. In the case of unions, get the name of the
--   first value in the union schema.
typeName :: Type -> Text

-- | <tt>buildTypeEnvironment schema</tt> 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.
buildTypeEnvironment :: Applicative m => (TypeName -> m Type) -> Schema -> TypeName -> m Type

-- | <tt>extractBindings schema</tt> 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.
extractBindings :: Type -> HashMap TypeName Type
data Result a
Success :: a -> Result a
Error :: String -> Result a
badValue :: Show t => t -> String -> Result a
resultToEither :: Result b -> Either String b

-- | Checks that two schemas match. This is like equality of schemas,
--   except <tt>NamedTypes</tt> match against other types <i>with the same
--   name</i>.
--   
--   This extends recursively: two records match if they have the same
--   name, the same number of fields and the fields all match.
matches :: Type -> Type -> Bool

-- | 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.
parseBytes :: Text -> Result ByteString

-- | Turn a <tt>ByteString</tt> into a <a>Text</a> 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.
serializeBytes :: ByteString -> Text

-- | Parse JSON-encoded avro data.
parseAvroJSON :: (Type -> Value -> Result (Value Type)) -> (TypeName -> Maybe Type) -> Type -> Value -> Result (Value Type)

-- | Merge two schemas to produce a third. Specifically, <tt>overlay schema
--   reference</tt> fills in <tt>NamedTypes</tt> in <tt>schema</tt> using
--   any matching definitions from <tt>reference</tt>.
overlay :: Type -> Type -> Type

-- | Extract the named inner type definition as its own schema.
subdefinition :: Type -> Text -> Maybe Type
instance GHC.Show.Show a => GHC.Show.Show (Data.Avro.Schema.Result a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Avro.Schema.Result a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Avro.Schema.Result a)
instance Control.DeepSeq.NFData Data.Avro.Schema.Field
instance GHC.Generics.Generic Data.Avro.Schema.Field
instance GHC.Show.Show Data.Avro.Schema.Field
instance GHC.Classes.Eq Data.Avro.Schema.Field
instance Control.DeepSeq.NFData Data.Avro.Schema.Type
instance GHC.Generics.Generic Data.Avro.Schema.Type
instance GHC.Show.Show Data.Avro.Schema.Type
instance Control.DeepSeq.NFData Data.Avro.Schema.Order
instance GHC.Generics.Generic Data.Avro.Schema.Order
instance GHC.Show.Show Data.Avro.Schema.Order
instance GHC.Classes.Ord Data.Avro.Schema.Order
instance GHC.Classes.Eq Data.Avro.Schema.Order
instance Control.DeepSeq.NFData Data.Avro.Schema.TypeName
instance GHC.Generics.Generic Data.Avro.Schema.TypeName
instance GHC.Classes.Ord Data.Avro.Schema.TypeName
instance GHC.Classes.Eq Data.Avro.Schema.TypeName
instance GHC.Base.Monad Data.Avro.Schema.Result
instance GHC.Base.Functor Data.Avro.Schema.Result
instance Control.Monad.Fail.MonadFail Data.Avro.Schema.Result
instance Control.Monad.Error.Class.MonadError GHC.Base.String Data.Avro.Schema.Result
instance GHC.Base.Applicative Data.Avro.Schema.Result
instance GHC.Base.Alternative Data.Avro.Schema.Result
instance GHC.Base.MonadPlus Data.Avro.Schema.Result
instance GHC.Base.Semigroup (Data.Avro.Schema.Result a)
instance GHC.Base.Monoid (Data.Avro.Schema.Result a)
instance Data.Foldable.Foldable Data.Avro.Schema.Result
instance Data.Traversable.Traversable Data.Avro.Schema.Result
instance GHC.Classes.Eq Data.Avro.Schema.Type
instance Data.Aeson.Types.FromJSON.FromJSON Data.Avro.Schema.Type
instance Data.Aeson.Types.ToJSON.ToJSON Data.Avro.Schema.Type
instance Data.Aeson.Types.ToJSON.ToJSON (Data.Avro.Types.Value.Value Data.Avro.Schema.Type)
instance Data.Aeson.Types.ToJSON.ToJSON Data.Avro.Schema.Order
instance Data.Aeson.Types.FromJSON.FromJSON Data.Avro.Schema.Order
instance GHC.Show.Show Data.Avro.Schema.TypeName
instance Data.String.IsString Data.Avro.Schema.TypeName
instance Data.Hashable.Class.Hashable Data.Avro.Schema.TypeName

module Data.Avro.Deriving.NormSchema

-- | Extracts all the records from the schema (flattens the schema) Named
--   types get resolved when needed to include at least one "inlined"
--   schema in each record and to make each record self-contained. Note:
--   Namespaces are not really supported in this version. All the
--   namespaces (including inlined into full names) will be ignored during
--   names resolution.
extractDerivables :: Schema -> [Schema]
getTypes :: Type -> [(TypeName, Type)]
normSchema :: Schema -> State (Map TypeName Schema) Schema

module Data.Avro.HasAvroSchema
class HasAvroSchema a
schema :: HasAvroSchema a => Tagged a Type
schemaOf :: HasAvroSchema a => a -> Type
wrapTag :: (Type -> Type) -> Tagged a Type -> Tagged b Type
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Word.Word8
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Word.Word16
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Word.Word32
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Word.Word64
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Types.Bool
instance Data.Avro.HasAvroSchema.HasAvroSchema ()
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Types.Int
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Int.Int8
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Int.Int16
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Int.Int32
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Int.Int64
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Types.Double
instance Data.Avro.HasAvroSchema.HasAvroSchema GHC.Types.Float
instance Data.Avro.HasAvroSchema.HasAvroSchema Data.Text.Internal.Text
instance Data.Avro.HasAvroSchema.HasAvroSchema Data.Text.Internal.Lazy.Text
instance Data.Avro.HasAvroSchema.HasAvroSchema Data.ByteString.Internal.ByteString
instance Data.Avro.HasAvroSchema.HasAvroSchema Data.ByteString.Lazy.Internal.ByteString
instance (Data.Avro.HasAvroSchema.HasAvroSchema a, Data.Avro.HasAvroSchema.HasAvroSchema b) => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Either.Either a b)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Map.Internal.Map Data.Text.Internal.Text a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.HashMap.Base.HashMap Data.Text.Internal.Text a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Map.Internal.Map Data.Text.Internal.Lazy.Text a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.HashMap.Base.HashMap Data.Text.Internal.Lazy.Text a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Map.Internal.Map GHC.Base.String a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.HashMap.Base.HashMap GHC.Base.String a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (GHC.Maybe.Maybe a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema [a]
instance (Data.Avro.HasAvroSchema.HasAvroSchema a, GHC.Arr.Ix i) => Data.Avro.HasAvroSchema.HasAvroSchema (GHC.Arr.Array i a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Vector.Vector a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Vector.Unboxed.Base.Vector a)
instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Set.Internal.Set a)

module Data.Avro.ToAvro
class HasAvroSchema a => ToAvro a
toAvro :: ToAvro a => a -> Value Type
(.=) :: ToAvro a => Text -> a -> (Text, Value Type)
instance Data.Avro.ToAvro.ToAvro GHC.Types.Bool
instance Data.Avro.ToAvro.ToAvro ()
instance Data.Avro.ToAvro.ToAvro GHC.Types.Int
instance Data.Avro.ToAvro.ToAvro GHC.Int.Int32
instance Data.Avro.ToAvro.ToAvro GHC.Int.Int64
instance Data.Avro.ToAvro.ToAvro GHC.Types.Double
instance Data.Avro.ToAvro.ToAvro GHC.Types.Float
instance Data.Avro.ToAvro.ToAvro Data.Text.Internal.Text
instance Data.Avro.ToAvro.ToAvro Data.Text.Internal.Lazy.Text
instance Data.Avro.ToAvro.ToAvro Data.ByteString.Internal.ByteString
instance Data.Avro.ToAvro.ToAvro Data.ByteString.Lazy.Internal.ByteString
instance (Data.Avro.ToAvro.ToAvro a, Data.Avro.ToAvro.ToAvro b) => Data.Avro.ToAvro.ToAvro (Data.Either.Either a b)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.Map.Internal.Map Data.Text.Internal.Text a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.HashMap.Base.HashMap Data.Text.Internal.Text a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.Map.Internal.Map Data.Text.Internal.Lazy.Text a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.HashMap.Base.HashMap Data.Text.Internal.Lazy.Text a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.Map.Internal.Map GHC.Base.String a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.HashMap.Base.HashMap GHC.Base.String a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (GHC.Maybe.Maybe a)
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro [a]
instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (Data.Vector.Vector a)
instance (Data.Vector.Unboxed.Base.Unbox a, Data.Avro.ToAvro.ToAvro a) => Data.Avro.ToAvro.ToAvro (Data.Vector.Unboxed.Base.Vector a)

module Data.Avro.Deconflict

-- | <tt>deconflict writer reader val</tt> will convert a value that was
--   encoded/decoded with the writer's schema into the form specified by
--   the reader's schema.
deconflict :: Schema -> Schema -> Value Type -> Either String (Value Type)

module Data.Avro.Decode.Lazy.Convert
toStrictValue :: LazyValue f -> Either String (Value f)
fromStrictValue :: Value f -> LazyValue f

module Data.Avro.Decode.Lazy.Deconflict

-- | <tt>deconflict writer reader val</tt> will convert a value that was
--   encoded/decoded with the writer's schema into the form specified by
--   the reader's schema.
deconflict :: Schema -> Schema -> LazyValue Type -> LazyValue Type

module Data.Avro.Zag
class Zag a where {
    type family Zagged a;
}
zag :: Zag a => a -> Zagged a
instance Data.Avro.Zag.Zag GHC.Word.Word8
instance Data.Avro.Zag.Zag GHC.Word.Word16
instance Data.Avro.Zag.Zag GHC.Word.Word32
instance Data.Avro.Zag.Zag GHC.Word.Word64
instance Data.Avro.Zag.Zag GHC.Types.Word

module Data.Avro.DecodeRaw
class DecodeRaw a
decodeRaw :: DecodeRaw a => Get a
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Types.Word
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Word.Word8
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Word.Word16
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Word.Word32
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Word.Word64
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Types.Int
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Int.Int8
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Int.Int16
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Int.Int32
instance Data.Avro.DecodeRaw.DecodeRaw GHC.Int.Int64

module Data.Avro.Decode.Get
class GetAvro a
getAvro :: GetAvro a => Get a
data ContainerHeader
ContainerHeader :: !ByteString -> (forall a. Decompress a) -> !Schema -> ContainerHeader
[syncBytes] :: ContainerHeader -> !ByteString
[decompress] :: ContainerHeader -> forall a. Decompress a
[containedSchema] :: ContainerHeader -> !Schema
nrSyncBytes :: Integral sb => sb
getCodec :: Monad m => Maybe ByteString -> m Codec
getBoolean :: Get Bool

-- | Get a 32-bit int (zigzag encoded, max of 5 bytes)
getInt :: Get Int32

-- | Get a 64 bit int (zigzag encoded, max of 10 bytes)
getLong :: Get Int64

-- | Get an zigzag encoded integral value consuming bytes till the msb is
--   0.
getZigZag :: (Bits i, Integral i, DecodeRaw i) => Get i
getBytes :: Get ByteString
getString :: Get Text
getFloat :: Get Float
getDouble :: Get Double
getArray :: GetAvro ty => Get [ty]
getMap :: GetAvro ty => Get (Map Text ty)
sFromIntegral :: forall a b m. (Monad m, Bounded a, Bounded b, Integral a, Integral b) => a -> m b
instance Data.Avro.Decode.Get.GetAvro Data.Avro.Decode.Get.ContainerHeader
instance Data.Avro.Decode.Get.GetAvro ty => Data.Avro.Decode.Get.GetAvro (Data.Map.Internal.Map Data.Text.Internal.Text ty)
instance Data.Avro.Decode.Get.GetAvro GHC.Types.Bool
instance Data.Avro.Decode.Get.GetAvro GHC.Int.Int32
instance Data.Avro.Decode.Get.GetAvro GHC.Int.Int64
instance Data.Avro.Decode.Get.GetAvro Data.ByteString.Lazy.Internal.ByteString
instance Data.Avro.Decode.Get.GetAvro Data.ByteString.Internal.ByteString
instance Data.Avro.Decode.Get.GetAvro Data.Text.Internal.Text
instance Data.Avro.Decode.Get.GetAvro GHC.Types.Float
instance Data.Avro.Decode.Get.GetAvro GHC.Types.Double
instance Data.Avro.Decode.Get.GetAvro GHC.Base.String
instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro [a]
instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro (GHC.Maybe.Maybe a)
instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro (GHC.Arr.Array GHC.Types.Int a)
instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro (Data.Vector.Vector a)
instance (Data.Avro.Decode.Get.GetAvro a, GHC.Classes.Ord a) => Data.Avro.Decode.Get.GetAvro (Data.Set.Internal.Set a)

module Data.Avro.Decode.Strict.Internal
getAvroOf :: Schema -> Get (Value Type)

module Data.Avro.Decode

-- | Decode bytes into a <tt>Value</tt> as described by Schema.
decodeAvro :: Schema -> ByteString -> Either String (Value Type)
decodeContainer :: ByteString -> Either String (Schema, [[Value Type]])
decodeContainerWith :: (Schema -> Get a) -> ByteString -> Either String (Schema, [[a]])
getAvroOf :: Schema -> Get (Value Type)
class GetAvro a
getAvro :: GetAvro a => Get a

module Data.Avro.Zig
class Zig a where {
    type family Zigged a;
}
zig :: Zig a => a -> Zigged a
instance Data.Avro.Zig.Zig GHC.Int.Int8
instance Data.Avro.Zig.Zig GHC.Int.Int16
instance Data.Avro.Zig.Zig GHC.Int.Int32
instance Data.Avro.Zig.Zig GHC.Int.Int64
instance Data.Avro.Zig.Zig GHC.Types.Int

module Data.Avro.EncodeRaw
class EncodeRaw a
encodeRaw :: EncodeRaw a => a -> Builder
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Types.Word
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Word.Word8
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Word.Word16
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Word.Word32
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Word.Word64
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Types.Int
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Int.Int8
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Int.Int16
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Int.Int32
instance Data.Avro.EncodeRaw.EncodeRaw GHC.Int.Int64

module Data.Avro.Encode
getSchema :: forall a. EncodeAvro a => a -> Schema
encodeAvro :: EncodeAvro a => a -> ByteString

-- | Encode chunks of objects into a container, using 16 random bytes for
--   the synchronization markers. Blocks are compressed (or not) according
--   to the given <a>Codec</a> (<a>nullCodec</a> or <a>deflateCodec</a>).
encodeContainer :: EncodeAvro a => Codec -> Schema -> [[a]] -> IO ByteString

-- | Generates a new synchronization marker for encoding Avro containers
newSyncBytes :: IO ByteString

-- | Encode chunks of objects into a container, using the provided
--   ByteString as the synchronization markers.
encodeContainerWithSync :: EncodeAvro a => Codec -> Schema -> ByteString -> [[a]] -> ByteString

-- | Creates an Avro container header for a given schema.
containerHeaderWithSync :: Codec -> Schema -> ByteString -> Builder

-- | Packs a new container from a list of already encoded Avro blocks. Each
--   block is denoted as a pair of a number of objects within that block
--   and the block content.
packContainerBlocks :: Codec -> Schema -> [(Int, ByteString)] -> IO ByteString

-- | Packs a new container from a list of already encoded Avro blocks. Each
--   block is denoted as a pair of a number of objects within that block
--   and the block content.
packContainerBlocksWithSync :: Codec -> Schema -> ByteString -> [(Int, ByteString)] -> ByteString

-- | Packs a container from a given list of already encoded Avro values
--   Each bytestring should represent exactly one one value serialised to
--   Avro.
packContainerValues :: Codec -> Schema -> [[ByteString]] -> IO ByteString

-- | Packs a container from a given list of already encoded Avro values
--   Each bytestring should represent exactly one one value serialised to
--   Avro.
packContainerValuesWithSync :: Codec -> Schema -> ByteString -> [[ByteString]] -> ByteString
class EncodeAvro a
avro :: EncodeAvro a => a -> AvroM
class Zag a where {
    type family Zagged a;
}
zag :: Zag a => a -> Zagged a
putAvro :: EncodeAvro a => a -> Builder
instance Data.Avro.Encode.EncodeAvro GHC.Types.Int
instance Data.Avro.Encode.EncodeAvro GHC.Int.Int8
instance Data.Avro.Encode.EncodeAvro GHC.Int.Int16
instance Data.Avro.Encode.EncodeAvro GHC.Int.Int32
instance Data.Avro.Encode.EncodeAvro GHC.Int.Int64
instance Data.Avro.Encode.EncodeAvro GHC.Word.Word8
instance Data.Avro.Encode.EncodeAvro GHC.Word.Word16
instance Data.Avro.Encode.EncodeAvro GHC.Word.Word32
instance Data.Avro.Encode.EncodeAvro GHC.Word.Word64
instance Data.Avro.Encode.EncodeAvro Data.Text.Internal.Text
instance Data.Avro.Encode.EncodeAvro Data.Text.Internal.Lazy.Text
instance Data.Avro.Encode.EncodeAvro Data.ByteString.Lazy.Internal.ByteString
instance Data.Avro.Encode.EncodeAvro Data.ByteString.Internal.ByteString
instance Data.Avro.Encode.EncodeAvro GHC.Base.String
instance Data.Avro.Encode.EncodeAvro GHC.Types.Double
instance Data.Avro.Encode.EncodeAvro GHC.Types.Float
instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro [a]
instance (GHC.Arr.Ix i, Data.Avro.Encode.EncodeAvro a) => Data.Avro.Encode.EncodeAvro (GHC.Arr.Array i a)
instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (Data.Vector.Vector a)
instance (Data.Vector.Unboxed.Base.Unbox a, Data.Avro.Encode.EncodeAvro a) => Data.Avro.Encode.EncodeAvro (Data.Vector.Unboxed.Base.Vector a)
instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (Data.Set.Internal.Set a)
instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (Data.HashMap.Base.HashMap Data.Text.Internal.Text a)
instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (GHC.Maybe.Maybe a)
instance Data.Avro.Encode.EncodeAvro ()
instance Data.Avro.Encode.EncodeAvro GHC.Types.Bool
instance Data.Avro.Encode.EncodeAvro (Data.Avro.Types.Value.Value Data.Avro.Schema.Type)

module Data.Avro.FromAvro
class HasAvroSchema a => FromAvro a
fromAvro :: FromAvro a => Value Type -> Result a
(.:) :: FromAvro a => HashMap Text (Value Type) -> Text -> Result a
instance (Data.Avro.FromAvro.FromAvro a, Data.Avro.FromAvro.FromAvro b) => Data.Avro.FromAvro.FromAvro (Data.Either.Either a b)
instance Data.Avro.FromAvro.FromAvro GHC.Types.Bool
instance Data.Avro.FromAvro.FromAvro Data.ByteString.Internal.ByteString
instance Data.Avro.FromAvro.FromAvro Data.ByteString.Lazy.Internal.ByteString
instance Data.Avro.FromAvro.FromAvro GHC.Types.Int
instance Data.Avro.FromAvro.FromAvro GHC.Int.Int32
instance Data.Avro.FromAvro.FromAvro GHC.Int.Int64
instance Data.Avro.FromAvro.FromAvro GHC.Types.Double
instance Data.Avro.FromAvro.FromAvro GHC.Types.Float
instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (GHC.Maybe.Maybe a)
instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro [a]
instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (Data.Vector.Vector a)
instance (Data.Vector.Unboxed.Base.Unbox a, Data.Avro.FromAvro.FromAvro a) => Data.Avro.FromAvro.FromAvro (Data.Vector.Unboxed.Base.Vector a)
instance Data.Avro.FromAvro.FromAvro Data.Text.Internal.Text
instance Data.Avro.FromAvro.FromAvro Data.Text.Internal.Lazy.Text
instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (Data.Map.Internal.Map Data.Text.Internal.Text a)
instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (Data.HashMap.Base.HashMap Data.Text.Internal.Text a)

module Data.Avro.Decode.Lazy.FromLazyAvro

-- | <a>FromLazyAvro</a> is a clone of <tt>FromAvro</tt> except that it
--   works for lazy values (<a>LazyValue</a>).
--   
--   Decoding from <a>LazyValue</a> directly without converting to strict
--   <tt>Value</tt> and then <tt>FromAvro</tt> can be very beneficial from
--   the performance point of view.
class HasAvroSchema a => FromLazyAvro a
fromLazyAvro :: FromLazyAvro a => LazyValue Type -> Result a
(.~:) :: FromLazyAvro a => HashMap Text (LazyValue Type) -> Text -> Result a
instance (Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro b) => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Either.Either a b)
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Types.Bool
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro Data.ByteString.Internal.ByteString
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro Data.ByteString.Lazy.Internal.ByteString
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Types.Int
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Int.Int32
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Int.Int64
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Types.Double
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro GHC.Types.Float
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (GHC.Maybe.Maybe a)
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro [a]
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Vector.Vector a)
instance (Data.Vector.Unboxed.Base.Unbox a, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a) => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Vector.Unboxed.Base.Vector a)
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro Data.Text.Internal.Text
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro Data.Text.Internal.Lazy.Text
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Map.Internal.Map Data.Text.Internal.Text a)
instance Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.HashMap.Base.HashMap Data.Text.Internal.Text a)

module Data.Avro.Decode.Lazy

-- | Decode bytes into a <tt>Value</tt> as described by Schema.
decodeAvro :: Schema -> ByteString -> LazyValue Type

-- | Decodes the container as a lazy list of values of the requested type.
--   
--   The schema for the requested type will be de-conflicted with the
--   schema embedded with the container.
--   
--   Errors are reported as a part of the list and the list will stop at
--   first error. This means that the consumer will get all the "good"
--   content from the container until the error is detected, then this
--   error and then the list is finished.
decodeContainer :: forall a. FromLazyAvro a => ByteString -> [Either String a]

-- | Decodes the container as a lazy list of values of the requested type.
--   
--   The schema for the requested type will be de-conflicted with the
--   schema embedded with the container.
--   
--   The content of the container is returned as a list of "blocks" of
--   values inside this container, so the notion of blocks in the container
--   is preserved. Since decoding is lazy it should be safe to concat these
--   values into one lazy list.
--   
--   The "outer" error represents the error in opening the container itself
--   (including problems like reading schemas embedded into the container.)
--   
--   The "inner" errors represent problems in decoding individual values.
--   
--   Note that this function will not stop decoding at the first occurance
--   of the "inner" error, and will continue attempting decoding values, so
--   it is possible to get <a>Right</a> after <a>Left</a>. It is up to the
--   user to decide whether it is correct or not to continue after errors
--   (most likely it will not be correct).
--   
--   <a>decodeContainer</a> function makes a choice to stop after the first
--   error.
decodeContainer' :: forall a. FromLazyAvro a => ByteString -> Either String [[Either String a]]

-- | Same as <a>decodeContainer</a> but uses provided schema as a reader
--   schema for the container instead of the schema obtained from the type
--   of <tt>a</tt>.
--   
--   It is up to the user to make sure that the provided schema is
--   compatible with <tt>a</tt> and with the container's writer schema.
decodeContainerWithSchema :: FromLazyAvro a => Schema -> ByteString -> [Either String a]

-- | Same as <a>decodeContainer'</a> but uses provided schema as a reader
--   schema for the container instead of the schema obtained from the type
--   of <tt>a</tt>.
--   
--   It is up to the user to make sure that the provided schema is
--   compatible with <tt>a</tt> and with the container's writer schema.
decodeContainerWithSchema' :: FromLazyAvro a => Schema -> ByteString -> Either String [[Either String a]]

-- | Reads the container as a list of blocks without decoding them into
--   actual values.
--   
--   This can be useful for streaming <i> splitting </i> merging Avro
--   containers without paying the cost for Avro encoding/decoding.
--   
--   Each block is returned as a raw <a>ByteString</a> annotated with the
--   number of Avro values that are contained in this block.
--   
--   The "outer" error represents the error in opening the container itself
--   (including problems like reading schemas embedded into the container.)
decodeRawBlocks :: ByteString -> Either String (Schema, [Either String (Int, ByteString)])

-- | Decodes the container into a list of blocks of raw Avro values.
--   
--   The content of the container is returned as a list of "blocks" of
--   values inside this container, so the notion of blocks in the container
--   is preserved. Since decoding is lazy it should be safe to concat these
--   values into one lazy list.
--   
--   Each <tt>LazyValue</tt> can be an <a>Error</a> and this function
--   doesn't make any attempts of dealing with them leaving it up to the
--   user.
--   
--   The "outer" error represents the error in opening the container itself
--   (including problems like reading schemas embedded into the container.)
getContainerValues :: ByteString -> Either String (Schema, [[LazyValue Type]])
getContainerValuesWith :: (Schema -> ByteString -> (ByteString, LazyValue Type)) -> ByteString -> Either String (Schema, [[LazyValue Type]])

-- | Splits container into a list of individual avro-encoded values.
--   
--   This is particularly useful when slicing up containers into one or
--   more smaller files. By extracting the original bytestring it is
--   possible to avoid re-encoding data.
getContainerValuesBytes :: ByteString -> Either String (Schema, [Either String ByteString])

-- | Splits container into a list of individual avro-encoded values. This
--   version provides both encoded and decoded values.
--   
--   This is particularly useful when slicing up containers into one or
--   more smaller files. By extracting the original bytestring it is
--   possible to avoid re-encoding data.
getContainerValuesBytes' :: ByteString -> Either String (Schema, [Either String (Value Type, ByteString)])
getAvroOf :: Schema -> ByteString -> (ByteString, LazyValue Type)
class GetAvro a
getAvro :: GetAvro a => Get a

-- | <a>FromLazyAvro</a> is a clone of <tt>FromAvro</tt> except that it
--   works for lazy values (<a>LazyValue</a>).
--   
--   Decoding from <a>LazyValue</a> directly without converting to strict
--   <tt>Value</tt> and then <tt>FromAvro</tt> can be very beneficial from
--   the performance point of view.
class HasAvroSchema a => FromLazyAvro a
fromLazyAvro :: FromLazyAvro a => LazyValue Type -> Result a
(.~:) :: FromLazyAvro a => HashMap Text (LazyValue Type) -> Text -> Result a
data LazyValue f
Null :: LazyValue f
Boolean :: Bool -> LazyValue f
Int :: Int32 -> LazyValue f
Long :: Int64 -> LazyValue f
Float :: Float -> LazyValue f
Double :: Double -> LazyValue f
Bytes :: ByteString -> LazyValue f
String :: Text -> LazyValue f

-- | Dynamically enforced monomorphic type.
Array :: Vector (LazyValue f) -> LazyValue f

-- | Dynamically enforced monomorphic type
Map :: HashMap Text (LazyValue f) -> LazyValue f
Record :: f -> HashMap Text (LazyValue f) -> LazyValue f

-- | Set of union options, schema for selected option, and the actual
--   value.
Union :: NonEmpty f -> f -> LazyValue f -> LazyValue f
Fixed :: f -> ByteString -> LazyValue f

-- | An enum is a set of the possible symbols (the schema) and the selected
--   symbol
Enum :: f -> Int -> Text -> LazyValue f
Error :: !String -> LazyValue f
badValue :: Show t => t -> String -> Result a


-- | Avro encoding and decoding routines.
--   
--   This library provides a high level interface for encoding (and
--   decoding) Haskell values in Apache's Avro serialization format. The
--   goal is to match Aeson's API whenever reasonable, meaning user
--   experience with one effectively translate to the other.
--   
--   Avro RPC is not currently supported.
--   
--   <ul>
--   <li>*Library Structure**</li>
--   </ul>
--   
--   The library structure includes: * This module, <a>Avro</a>, providing
--   a high-level interface via classes of <a>FromAvro</a> and
--   <a>ToAvro</a> for decoding and encoding values. * <a>Type</a> define
--   the types of Avro data, providing a common (intermediate)
--   representation for any data that is encoded or decoded by Data.Avro. *
--   <a>Encode</a> and <a>Decode</a>: More efficient conversion capable of
--   avoiding the intermediate representation. Also, the implementation of
--   the en/decoding of the intermediate representation. *
--   <a>Deconflict</a>: translate decoded data from an encoder schema to
--   the (potentially different) decoder's schema. * <a>Schema</a>: Defines
--   the type for Avro schema's and its JSON encoding/decoding.
--   
--   Example decoding:
--   
--   Let's say you have an ADT and related schema:
--   
--   <pre>
--   {--}
--   import qualified Data.Avro.Types as Ty
--   import Data.Avro.Schema
--   import Data.Avro
--   import           Data.List.NonEmpty (NonEmpty(..))
--   
--   data MyEnum = A | B | C | D deriving (Eq,Ord,Show,Enum,Generic)
--   data MyStruct = MyStruct (Either MyEnum String) Int
--   
--   meSchema :: Schema
--   meSchema = Schema $ mkEnum <a>MyEnum</a> [] Nothing Nothing [<a>A</a>,<a>B</a>,<a>C</a>,<a>D</a>]
--   
--   msSchema  :: Schema
--   msSchema =
--     Struct <a>MyStruct</a> Nothing [] Nothing Nothing
--         [ fld "enumOrString" eOrS (Just $ String "The Default")
--         , fld "int" Int (Just (Ty.Int 1))
--         ]
--        where
--        fld nm ty def = Field nm [] Nothing Nothing ty def
--        eOrS = mkUnion (meSchema :| [String])
--   
--   instance ToAvro MyEnum where
--       toAvro = toAvroEnum
--   instance ToAvro MyStruct where
--       toAvro (MyStruct ab i) =
--        record [ "enumOrString" .= ab
--               , "int"          .= i
--               ]
--   
--   main = do
--     let val = MyStruct (Right <a>Hello</a>) 1
--     print (fromAvro (toAvro val) == Success val)
--   </pre>
module Data.Avro
class HasAvroSchema a => FromAvro a
fromAvro :: FromAvro a => Value Type -> Result a
class HasAvroSchema a => ToAvro a
toAvro :: ToAvro a => a -> Value Type
class HasAvroSchema a
schema :: HasAvroSchema a => Tagged a Type

-- | An Avro schema is either * A "JSON object in the form
--   `{"type":"typeName" ...` * A "JSON string, naming a defined type"
--   (basic type w<i>o free variables</i>names) * A "JSON array,
--   representing a union"
--   
--   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 <a>validateSchema</a>.
type Schema = Type
type Avro a = (FromAvro a, ToAvro a)
(.:) :: FromAvro a => HashMap Text (Value Type) -> Text -> Result a
(.=) :: ToAvro a => Text -> a -> (Text, Value Type)
record :: Foldable f => Type -> f (Text, Value Type) -> Value Type
fixed :: Type -> ByteString -> Value Type
data Result a
Success :: a -> Result a
Error :: String -> Result a
badValue :: Show t => t -> String -> Result a

-- | Decode a lazy bytestring using a Schema for the return type.
decode :: forall a. FromAvro a => ByteString -> Result a

-- | Decode a lazy bytestring with a provided schema
decodeWithSchema :: FromAvro a => Schema -> ByteString -> Result a

-- | Decode a container and de-conflict the writer schema with a reader
--   schema for a return type. Like in <a>decodeContainerWithSchema</a>
--   exceptions are thrown instead of a <a>Result</a> type to allow this
--   function to be read lazy (to be done in some later version).
decodeContainer :: forall a. FromAvro a => ByteString -> [[a]]

-- | Decode a container and de-conflict the writer schema with a given
--   reader-schema. Exceptions are thrown instead of a <a>Result</a> type
--   to allow this function to be read lazy (to be done in some later
--   version).
decodeContainerWithSchema :: FromAvro a => Schema -> ByteString -> [[a]]

-- | Like <a>decodeContainer</a> but returns the avro-encoded bytes for
--   each object in the container instead of the Haskell type.
--   
--   This is particularly useful when slicing up containers into one or
--   more smaller files. By extracting the original bytestring it is
--   possible to avoid re-encoding data.
decodeContainerBytes :: ByteString -> [[ByteString]]

-- | Encodes a value to a lazy ByteString
encode :: ToAvro a => a -> ByteString

-- | Encode chunks of objects into a container, using 16 random bytes for
--   the synchronization markers.
encodeContainer :: forall a. ToAvro a => [[a]] -> IO ByteString

-- | Encode chunks of objects into a container, using the provided
--   ByteString as the synchronization markers.
encodeContainerWithSync :: forall a. ToAvro a => (Word64, Word64, Word64, Word64) -> [[a]] -> ByteString
schemaOf :: HasAvroSchema a => a -> Type


-- | Avro supports a JSON representation of Avro objects alongside the Avro
--   binary format. An Avro schema can be used to generate and validate
--   JSON representations of Avro objects.
--   
--   The JSON format is the same format as used for default values in
--   schemas except unions are encoded differently. Non-union values are
--   encoded as follows:
--   
--   TODO: table
--   
--   (Table from the Avro 1.8.2 specification:
--   <a>https://avro.apache.org/docs/1.8.2/spec.html#schema_record</a>)
--   
--   Bytes and fixed are encoded as JSON strings where each byte is
--   translated into the corresponding Unicode codepoint between 0–255,
--   which includes non-printable characters. Note that this encoding
--   happens at the Unicode code-point level, meaning it is independent of
--   text encoding. (JSON is, by definition, encoded in UTF8.)
--   
--   Unions are encoded as an object with a single field that specifies the
--   "branch" of the union. If the branch is a primitive type like
--   <tt>"string"</tt>, the name of the primitive type is used:
--   
--   <pre>
--   { "string" : "foo" }
--   </pre>
--   
--   For named types (record, enum and fixed), the name of the type is
--   used:
--   
--   <pre>
--   { <a>MyRecord</a> : { ... } }
--   </pre>
module Data.Avro.JSON
decodeAvroJSON :: Schema -> Value -> Result (Value Schema)

-- | Convert a <a>Value</a> into a type that has an Avro schema. The schema
--   is used to validate the JSON and will return an <a>Error</a> if the
--   JSON object is not encoded correctly or does not match the schema.
fromJSON :: forall a. FromAvro a => Value -> Result a

-- | Parse a <a>ByteString</a> as JSON and convert it to a type with an
--   Avro schema. Will return <a>Error</a> if the input is not valid JSON
--   or the JSON does not convert with the specified schema.
parseJSON :: forall a. FromAvro a => ByteString -> Result a

-- | Convert an object with an Avro schema to JSON using that schema.
--   
--   We always need the schema to <i>encode</i> to JSON because
--   representing unions requires using the names of named types.
toJSON :: forall a. ToAvro a => a -> Value

module Data.Avro.EitherN
data Either3 a b c
E3_1 :: a -> Either3 a b c
E3_2 :: b -> Either3 a b c
E3_3 :: c -> Either3 a b c
data Either4 a b c d
E4_1 :: a -> Either4 a b c d
E4_2 :: b -> Either4 a b c d
E4_3 :: c -> Either4 a b c d
E4_4 :: d -> Either4 a b c d
data Either5 a b c d e
E5_1 :: a -> Either5 a b c d e
E5_2 :: b -> Either5 a b c d e
E5_3 :: c -> Either5 a b c d e
E5_4 :: d -> Either5 a b c d e
E5_5 :: e -> Either5 a b c d e
instance Data.Traversable.Traversable (Data.Avro.EitherN.Either5 a b c d)
instance Data.Foldable.Foldable (Data.Avro.EitherN.Either5 a b c d)
instance GHC.Base.Functor (Data.Avro.EitherN.Either5 a b c d)
instance GHC.Generics.Generic (Data.Avro.EitherN.Either5 a b c d e)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d, GHC.Show.Show e) => GHC.Show.Show (Data.Avro.EitherN.Either5 a b c d e)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b, GHC.Classes.Ord c, GHC.Classes.Ord d, GHC.Classes.Ord e) => GHC.Classes.Ord (Data.Avro.EitherN.Either5 a b c d e)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b, GHC.Classes.Eq c, GHC.Classes.Eq d, GHC.Classes.Eq e) => GHC.Classes.Eq (Data.Avro.EitherN.Either5 a b c d e)
instance Data.Traversable.Traversable (Data.Avro.EitherN.Either4 a b c)
instance Data.Foldable.Foldable (Data.Avro.EitherN.Either4 a b c)
instance GHC.Base.Functor (Data.Avro.EitherN.Either4 a b c)
instance GHC.Generics.Generic (Data.Avro.EitherN.Either4 a b c d)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d) => GHC.Show.Show (Data.Avro.EitherN.Either4 a b c d)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b, GHC.Classes.Ord c, GHC.Classes.Ord d) => GHC.Classes.Ord (Data.Avro.EitherN.Either4 a b c d)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b, GHC.Classes.Eq c, GHC.Classes.Eq d) => GHC.Classes.Eq (Data.Avro.EitherN.Either4 a b c d)
instance Data.Traversable.Traversable (Data.Avro.EitherN.Either3 a b)
instance Data.Foldable.Foldable (Data.Avro.EitherN.Either3 a b)
instance GHC.Base.Functor (Data.Avro.EitherN.Either3 a b)
instance GHC.Generics.Generic (Data.Avro.EitherN.Either3 a b c)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c) => GHC.Show.Show (Data.Avro.EitherN.Either3 a b c)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b, GHC.Classes.Ord c) => GHC.Classes.Ord (Data.Avro.EitherN.Either3 a b c)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b, GHC.Classes.Eq c) => GHC.Classes.Eq (Data.Avro.EitherN.Either3 a b c)
instance GHC.Base.Applicative (Data.Avro.EitherN.Either5 a b c d)
instance Data.Bifunctor.Bifunctor (Data.Avro.EitherN.Either5 a b c)
instance GHC.Base.Monad (Data.Avro.EitherN.Either5 a b c d)
instance Data.Bifoldable.Bifoldable (Data.Avro.EitherN.Either5 a b c)
instance Data.Bitraversable.Bitraversable (Data.Avro.EitherN.Either5 a b c)
instance (Data.Avro.HasAvroSchema.HasAvroSchema a, Data.Avro.HasAvroSchema.HasAvroSchema b, Data.Avro.HasAvroSchema.HasAvroSchema c, Data.Avro.HasAvroSchema.HasAvroSchema d, Data.Avro.HasAvroSchema.HasAvroSchema e) => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Avro.EitherN.Either5 a b c d e)
instance (Data.Avro.FromAvro.FromAvro a, Data.Avro.FromAvro.FromAvro b, Data.Avro.FromAvro.FromAvro c, Data.Avro.FromAvro.FromAvro d, Data.Avro.FromAvro.FromAvro e) => Data.Avro.FromAvro.FromAvro (Data.Avro.EitherN.Either5 a b c d e)
instance (Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro b, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro c, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro d, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro e) => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Avro.EitherN.Either5 a b c d e)
instance (Data.Avro.ToAvro.ToAvro a, Data.Avro.ToAvro.ToAvro b, Data.Avro.ToAvro.ToAvro c, Data.Avro.ToAvro.ToAvro d, Data.Avro.ToAvro.ToAvro e) => Data.Avro.ToAvro.ToAvro (Data.Avro.EitherN.Either5 a b c d e)
instance GHC.Base.Applicative (Data.Avro.EitherN.Either4 a b c)
instance Data.Bifunctor.Bifunctor (Data.Avro.EitherN.Either4 a b)
instance GHC.Base.Monad (Data.Avro.EitherN.Either4 a b c)
instance Data.Bifoldable.Bifoldable (Data.Avro.EitherN.Either4 a b)
instance Data.Bitraversable.Bitraversable (Data.Avro.EitherN.Either4 a b)
instance (Data.Avro.HasAvroSchema.HasAvroSchema a, Data.Avro.HasAvroSchema.HasAvroSchema b, Data.Avro.HasAvroSchema.HasAvroSchema c, Data.Avro.HasAvroSchema.HasAvroSchema d) => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Avro.EitherN.Either4 a b c d)
instance (Data.Avro.FromAvro.FromAvro a, Data.Avro.FromAvro.FromAvro b, Data.Avro.FromAvro.FromAvro c, Data.Avro.FromAvro.FromAvro d) => Data.Avro.FromAvro.FromAvro (Data.Avro.EitherN.Either4 a b c d)
instance (Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro b, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro c, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro d) => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Avro.EitherN.Either4 a b c d)
instance (Data.Avro.ToAvro.ToAvro a, Data.Avro.ToAvro.ToAvro b, Data.Avro.ToAvro.ToAvro c, Data.Avro.ToAvro.ToAvro d) => Data.Avro.ToAvro.ToAvro (Data.Avro.EitherN.Either4 a b c d)
instance GHC.Base.Applicative (Data.Avro.EitherN.Either3 a b)
instance Data.Bifunctor.Bifunctor (Data.Avro.EitherN.Either3 a)
instance GHC.Base.Monad (Data.Avro.EitherN.Either3 a b)
instance Data.Bifoldable.Bifoldable (Data.Avro.EitherN.Either3 a)
instance Data.Bitraversable.Bitraversable (Data.Avro.EitherN.Either3 a)
instance (Data.Avro.HasAvroSchema.HasAvroSchema a, Data.Avro.HasAvroSchema.HasAvroSchema b, Data.Avro.HasAvroSchema.HasAvroSchema c) => Data.Avro.HasAvroSchema.HasAvroSchema (Data.Avro.EitherN.Either3 a b c)
instance (Data.Avro.FromAvro.FromAvro a, Data.Avro.FromAvro.FromAvro b, Data.Avro.FromAvro.FromAvro c) => Data.Avro.FromAvro.FromAvro (Data.Avro.EitherN.Either3 a b c)
instance (Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro a, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro b, Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro c) => Data.Avro.Decode.Lazy.FromLazyAvro.FromLazyAvro (Data.Avro.EitherN.Either3 a b c)
instance (Data.Avro.ToAvro.ToAvro a, Data.Avro.ToAvro.ToAvro b, Data.Avro.ToAvro.ToAvro c) => Data.Avro.ToAvro.ToAvro (Data.Avro.EitherN.Either3 a b c)


-- | This module lets us derive Haskell types from an Avro schema that can
--   be serialized/deserialzed to Avro.
module Data.Avro.Deriving

-- | Derives Avro from a given schema file. Generates data types, FromAvro
--   and ToAvro instances.
data DeriveOptions
DeriveOptions :: (Text -> Field -> Text) -> (TypeName -> Field -> (FieldStrictness, FieldUnpackedness)) -> NamespaceBehavior -> DeriveOptions

-- | How to build field names for generated data types. The first argument
--   is the type name to use as a prefix, rendered according to the
--   <a>namespaceBehavior</a> setting.
[fieldNameBuilder] :: DeriveOptions -> Text -> Field -> Text

-- | Determines field representation of generated data types
[fieldRepresentation] :: DeriveOptions -> TypeName -> Field -> (FieldStrictness, FieldUnpackedness)

-- | Controls how we handle namespaces when defining Haskell type and field
--   names.
[namespaceBehavior] :: DeriveOptions -> NamespaceBehavior

-- | Describes the strictness of a field for a derived data type. The field
--   will be derived as if it were written with a <tt>!</tt>.
data FieldStrictness
StrictField :: FieldStrictness
LazyField :: FieldStrictness

-- | Describes the representation of a field for a derived data type. The
--   field will be derived as if it were written with an <tt>{--}</tt>
--   pragma.
data FieldUnpackedness
UnpackedField :: FieldUnpackedness
NonUnpackedField :: FieldUnpackedness

-- | How to treat Avro namespaces in the generated Haskell types.
data NamespaceBehavior

-- | Namespaces are ignored completely. Haskell identifiers are generated
--   from types' base names. This produces nicer types but fails on valid
--   Avro schemas where the same base name occurs in different namespaces.
--   
--   The Avro type <tt>com.example.Foo</tt> would generate the Haskell type
--   <tt>Foo</tt>. If <tt>Foo</tt> had a field called <tt>bar</tt>, the
--   generated Haskell record would have a field called <tt>fooBar</tt>.
IgnoreNamespaces :: NamespaceBehavior

-- | Haskell types and field names are generated with namespaces. See
--   <tt>deriveAvroWithNamespaces</tt> for an example of how this works.
--   
--   The Avro type <tt>com.example.Foo</tt> would generate the Haskell type
--   <tt>Com<tt>example</tt>Foo</tt>. If <tt>Foo</tt> had a field called
--   <tt>bar</tt>, the generated Haskell record would have the field
--   <tt>com<tt>example</tt>FooBar</tt>.
HandleNamespaces :: NamespaceBehavior

-- | Default deriving options
--   
--   <pre>
--   defaultDeriveOptions = <a>DeriveOptions</a>
--     { fieldNameBuilder  = <a>mkPrefixedFieldName</a>
--     , fieldStrictness   = <a>mkLazyField</a>
--     , namespaceBehavior = <a>IgnoreNamespaces</a>
--     }
--   </pre>
defaultDeriveOptions :: DeriveOptions

-- | Generates a field name that is prefixed with the type name.
--   
--   For example, if the schema defines type <tt>Person</tt> that has a
--   field <tt>firstName</tt>, then the generated Haskell type will be like
--   
--   <pre>
--   Person { personFirstName :: Text }
--   </pre>
mkPrefixedFieldName :: Text -> Field -> Text

-- | 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 <tt>Person</tt> that has a
--   field <tt>firstName</tt>, then the generated Haskell type will be like
--   
--   <pre>
--   Person { firstName :: Text }
--   </pre>
--   
--   You may want to enable <a>DuplicateRecordFields</a> if you want to use
--   this method.
mkAsIsFieldName :: Text -> Field -> Text

-- | Marks any field as non-strict in the generated data types.
mkLazyField :: TypeName -> Field -> (FieldStrictness, FieldUnpackedness)

-- | Make a field strict and unpacked if it has a primitive representation.
--   Primitive types are types which GHC has either a static or an unlifted
--   representation: `()`, <a>Boolean</a>, <a>Int32</a>, <a>Int64</a>,
--   <a>Type</a>, <a>Type</a>.
mkStrictPrimitiveField :: TypeName -> Field -> (FieldStrictness, FieldUnpackedness)

-- | Generates the value of type <a>Schema</a> that it can later be used
--   with <a>deriveAvro'</a> or <a>deriveAvroWithOptions'</a>.
--   
--   <pre>
--   mySchema :: Schema
--   mySchema = $(makeSchema "schemas/my-schema.avsc")
--   </pre>
makeSchema :: FilePath -> Q Exp
makeSchemaFrom :: FilePath -> Text -> Q Exp

-- | Derives Haskell types from the given Avro schema file. These Haskell
--   types support both reading and writing to Avro.
--   
--   For an Avro schema with a top-level record called
--   <tt>com.example.Foo</tt>, this generates:
--   
--   <ul>
--   <li>a <a>Schema</a> with the name <tt>schema'Foo</tt> or
--   <tt>schema<tt>com'example</tt>Foo</tt>, depending on the
--   <a>namespaceBehavior</a> setting.</li>
--   <li>Haskell types for each named type defined in the schema</li>
--   <li><tt>HasSchema</tt> instances for each type</li>
--   <li><a>FromAvro</a> instances for each type</li>
--   <li><a>ToAvro</a> instances for each type</li>
--   </ul>
--   
--   This function ignores namespaces when generated Haskell type and field
--   names. This will fail on valid Avro schemas which contain types with
--   the same base name in different namespaces. It will also fail for
--   schemas that contain types with base names that are the same except
--   for the capitalization of the first letter.
--   
--   The type <tt>com.example.Foo</tt> will generate a Haskell type
--   <tt>Foo</tt>. If <tt>com.example.Foo</tt> has a field named
--   <tt>Bar</tt>, the field in the Haskell record will be called
--   <tt>fooBar</tt>.
deriveAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec]

-- | Derive Haskell types from the given Avro schema.
--   
--   For an Avro schema with a top-level definition
--   <tt>com.example.Foo</tt>, this generates:
--   
--   <ul>
--   <li>a <a>Schema</a> with the name <tt>schema'Foo</tt> or
--   <tt>schema<tt>com'example</tt>Foo</tt> depending on namespace
--   handling</li>
--   <li>Haskell types for each named type defined in the schema</li>
--   <li><tt>HasSchema</tt> instances for each type</li>
--   <li><a>FromAvro</a> instances for each type</li>
--   <li><a>ToAvro</a> instances for each type</li>
--   </ul>
deriveAvroWithOptions' :: DeriveOptions -> Schema -> Q [Dec]

-- | Derives "read only" Avro from a given schema file. For a schema with a
--   top-level definition <tt>com.example.Foo</tt>, this generates:
--   
--   <ul>
--   <li>a <a>Schema</a> value with the name <tt>schema'Foo</tt></li>
--   <li>Haskell types for each named type defined in the schema</li>
--   <li><tt>HasSchema</tt> instances for each type</li>
--   <li><a>FromAvro</a> instances for each type</li>
--   </ul>
deriveFromAvroWithOptions :: DeriveOptions -> FilePath -> Q [Dec]

-- | Same as <a>deriveAvroWithOptions</a> but uses
--   <a>defaultDeriveOptions</a>
--   
--   <pre>
--   deriveAvro = <a>deriveAvroWithOptions</a> <a>defaultDeriveOptions</a>
--   </pre>
deriveAvro :: FilePath -> Q [Dec]

-- | Same as <a>deriveAvroWithOptions'</a> but uses
--   <a>defaultDeriveOptions</a>
--   
--   <pre>
--   deriveAvro' = <a>deriveAvroWithOptions'</a> <a>defaultDeriveOptions</a>
--   </pre>
deriveAvro' :: Schema -> Q [Dec]

-- | Same as <a>deriveFromAvroWithOptions</a> but uses
--   <a>defaultDeriveOptions</a>.
--   
--   <pre>
--   deriveFromAvro = deriveFromAvroWithOptions defaultDeriveOptions
--   </pre>
deriveFromAvro :: FilePath -> Q [Dec]
instance GHC.Generics.Generic Data.Avro.Deriving.DeriveOptions
instance GHC.Generics.Generic Data.Avro.Deriving.FieldUnpackedness
instance GHC.Generics.Generic Data.Avro.Deriving.FieldStrictness
