packages feed

avro 0.4.5.4 → 0.4.6.0

raw patch · 22 files changed

+369/−353 lines, 22 filesdep +doctestdep +doctest-discoverdep −pure-zlibPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: doctest, doctest-discover

Dependencies removed: pure-zlib

API changes (from Hackage documentation)

- Data.Avro: type Schema = Type
- Data.Avro.Deriving.Lift: instance Language.Haskell.TH.Syntax.Lift Data.Avro.Schema.Type
- Data.Avro.Encode: instance Data.Avro.Encode.EncodeAvro (Data.Avro.Types.Value.Value Data.Avro.Schema.Type)
- Data.Avro.Schema: data Type
- Data.Avro.Schema: instance Control.DeepSeq.NFData Data.Avro.Schema.Type
- Data.Avro.Schema: instance Data.Aeson.Types.FromJSON.FromJSON Data.Avro.Schema.Type
- Data.Avro.Schema: instance Data.Aeson.Types.ToJSON.ToJSON (Data.Avro.Types.Value.Value Data.Avro.Schema.Type)
- Data.Avro.Schema: instance Data.Aeson.Types.ToJSON.ToJSON Data.Avro.Schema.Type
- Data.Avro.Schema: instance GHC.Classes.Eq Data.Avro.Schema.Type
- Data.Avro.Schema: instance GHC.Generics.Generic Data.Avro.Schema.Type
- Data.Avro.Schema: instance GHC.Show.Show Data.Avro.Schema.Type
- Data.Avro.Schema: type Schema = Type
+ Data.Avro: data Schema
+ Data.Avro.Deriving.Lift: instance Language.Haskell.TH.Syntax.Lift Data.Avro.Schema.Schema
+ Data.Avro.Encode: instance Data.Avro.Encode.EncodeAvro (Data.Avro.Types.Value.Value Data.Avro.Schema.Schema)
+ Data.Avro.Schema: data Schema
+ Data.Avro.Schema: instance Control.DeepSeq.NFData Data.Avro.Schema.Schema
+ Data.Avro.Schema: instance Data.Aeson.Types.FromJSON.FromJSON Data.Avro.Schema.Schema
+ Data.Avro.Schema: instance Data.Aeson.Types.ToJSON.ToJSON (Data.Avro.Types.Value.Value Data.Avro.Schema.Schema)
+ Data.Avro.Schema: instance Data.Aeson.Types.ToJSON.ToJSON Data.Avro.Schema.Schema
+ Data.Avro.Schema: instance GHC.Classes.Eq Data.Avro.Schema.Schema
+ Data.Avro.Schema: instance GHC.Generics.Generic Data.Avro.Schema.Schema
+ Data.Avro.Schema: instance GHC.Show.Show Data.Avro.Schema.Schema
+ Data.Avro.Schema: type Type = Schema
- Data.Avro: (.:) :: FromAvro a => HashMap Text (Value Type) -> Text -> Result a
+ Data.Avro: (.:) :: FromAvro a => HashMap Text (Value Schema) -> Text -> Result a
- Data.Avro: (.=) :: ToAvro a => Text -> a -> (Text, Value Type)
+ Data.Avro: (.=) :: ToAvro a => Text -> a -> (Text, Value Schema)
- Data.Avro: fixed :: Type -> ByteString -> Value Type
+ Data.Avro: fixed :: Schema -> ByteString -> Value Schema
- Data.Avro: fromAvro :: FromAvro a => Value Type -> Result a
+ Data.Avro: fromAvro :: FromAvro a => Value Schema -> Result a
- Data.Avro: record :: Foldable f => Type -> f (Text, Value Type) -> Value Type
+ Data.Avro: record :: Foldable f => Schema -> f (Text, Value Schema) -> Value Schema
- Data.Avro: schema :: HasAvroSchema a => Tagged a Type
+ Data.Avro: schema :: HasAvroSchema a => Tagged a Schema
- Data.Avro: schemaOf :: HasAvroSchema a => a -> Type
+ Data.Avro: schemaOf :: HasAvroSchema a => a -> Schema
- Data.Avro: toAvro :: ToAvro a => a -> Value Type
+ Data.Avro: toAvro :: ToAvro a => a -> Value Schema
- Data.Avro.Decode: decodeAvro :: Schema -> ByteString -> Either String (Value Type)
+ Data.Avro.Decode: decodeAvro :: Schema -> ByteString -> Either String (Value Schema)
- Data.Avro.Decode: decodeContainer :: ByteString -> Either String (Schema, [[Value Type]])
+ Data.Avro.Decode: decodeContainer :: ByteString -> Either String (Schema, [[Value Schema]])
- Data.Avro.Decode: getAvroOf :: Schema -> Get (Value Type)
+ Data.Avro.Decode: getAvroOf :: Schema -> Get (Value Schema)
- Data.Avro.Decode.Lazy: (.~:) :: FromLazyAvro a => HashMap Text (LazyValue Type) -> Text -> Result a
+ Data.Avro.Decode.Lazy: (.~:) :: FromLazyAvro a => HashMap Text (LazyValue Schema) -> Text -> Result a
- Data.Avro.Decode.Lazy: decodeAvro :: Schema -> ByteString -> LazyValue Type
+ Data.Avro.Decode.Lazy: decodeAvro :: Schema -> ByteString -> LazyValue Schema
- Data.Avro.Decode.Lazy: fromLazyAvro :: FromLazyAvro a => LazyValue Type -> Result a
+ Data.Avro.Decode.Lazy: fromLazyAvro :: FromLazyAvro a => LazyValue Schema -> Result a
- Data.Avro.Decode.Lazy: getAvroOf :: Schema -> ByteString -> (ByteString, LazyValue Type)
+ Data.Avro.Decode.Lazy: getAvroOf :: Schema -> ByteString -> (ByteString, LazyValue Schema)
- Data.Avro.Decode.Lazy: getContainerValues :: ByteString -> Either String (Schema, [[LazyValue Type]])
+ Data.Avro.Decode.Lazy: getContainerValues :: ByteString -> Either String (Schema, [[LazyValue Schema]])
- Data.Avro.Decode.Lazy: getContainerValuesBytes' :: ByteString -> Either String (Schema, [Either String (Value Type, ByteString)])
+ Data.Avro.Decode.Lazy: getContainerValuesBytes' :: ByteString -> Either String (Schema, [Either String (Value Schema, ByteString)])
- Data.Avro.Decode.Lazy: getContainerValuesWith :: (Schema -> ByteString -> (ByteString, LazyValue Type)) -> ByteString -> Either String (Schema, [[LazyValue Type]])
+ Data.Avro.Decode.Lazy: getContainerValuesWith :: (Schema -> ByteString -> (ByteString, LazyValue Schema)) -> ByteString -> Either String (Schema, [[LazyValue Schema]])
- Data.Avro.Decode.Lazy.Deconflict: deconflict :: Schema -> Schema -> LazyValue Type -> LazyValue Type
+ Data.Avro.Decode.Lazy.Deconflict: deconflict :: Schema -> Schema -> LazyValue Schema -> LazyValue Schema
- Data.Avro.Decode.Lazy.Deconflict: deconflictNoResolve :: Schema -> Schema -> LazyValue Type -> LazyValue Type
+ Data.Avro.Decode.Lazy.Deconflict: deconflictNoResolve :: Schema -> Schema -> LazyValue Schema -> LazyValue Schema
- Data.Avro.Decode.Lazy.FromLazyAvro: (.~:) :: FromLazyAvro a => HashMap Text (LazyValue Type) -> Text -> Result a
+ Data.Avro.Decode.Lazy.FromLazyAvro: (.~:) :: FromLazyAvro a => HashMap Text (LazyValue Schema) -> Text -> Result a
- Data.Avro.Decode.Lazy.FromLazyAvro: fromLazyAvro :: FromLazyAvro a => LazyValue Type -> Result a
+ Data.Avro.Decode.Lazy.FromLazyAvro: fromLazyAvro :: FromLazyAvro a => LazyValue Schema -> Result a
- Data.Avro.Decode.Strict.Internal: getAvroOf :: Schema -> Get (Value Type)
+ Data.Avro.Decode.Strict.Internal: getAvroOf :: Schema -> Get (Value Schema)
- Data.Avro.Deconflict: deconflict :: Schema -> Schema -> Value Type -> Either String (Value Type)
+ Data.Avro.Deconflict: deconflict :: Schema -> Schema -> Value Schema -> Either String (Value Schema)
- Data.Avro.Deconflict: deconflictNoResolve :: Schema -> Schema -> Value Type -> Either String (Value Type)
+ Data.Avro.Deconflict: deconflictNoResolve :: Schema -> Schema -> Value Schema -> Either String (Value Schema)
- Data.Avro.Deriving.NormSchema: getTypes :: Type -> [(TypeName, Type)]
+ Data.Avro.Deriving.NormSchema: getTypes :: Schema -> [(TypeName, Schema)]
- Data.Avro.FromAvro: (.:) :: FromAvro a => HashMap Text (Value Type) -> Text -> Result a
+ Data.Avro.FromAvro: (.:) :: FromAvro a => HashMap Text (Value Schema) -> Text -> Result a
- Data.Avro.FromAvro: fromAvro :: FromAvro a => Value Type -> Result a
+ Data.Avro.FromAvro: fromAvro :: FromAvro a => Value Schema -> Result a
- Data.Avro.HasAvroSchema: schema :: HasAvroSchema a => Tagged a Type
+ Data.Avro.HasAvroSchema: schema :: HasAvroSchema a => Tagged a Schema
- Data.Avro.HasAvroSchema: schemaOf :: HasAvroSchema a => a -> Type
+ Data.Avro.HasAvroSchema: schemaOf :: HasAvroSchema a => a -> Schema
- Data.Avro.HasAvroSchema: wrapTag :: (Type -> Type) -> Tagged a Type -> Tagged b Type
+ Data.Avro.HasAvroSchema: wrapTag :: (Schema -> Schema) -> Tagged a Schema -> Tagged b Schema
- Data.Avro.Schema: Array :: Type -> Type
+ Data.Avro.Schema: Array :: Schema -> Schema
- Data.Avro.Schema: Boolean :: Type
+ Data.Avro.Schema: Boolean :: Schema
- Data.Avro.Schema: Bytes :: Type
+ Data.Avro.Schema: Bytes :: Schema
- Data.Avro.Schema: Double :: Type
+ Data.Avro.Schema: Double :: Schema
- Data.Avro.Schema: Enum :: TypeName -> [TypeName] -> Maybe Text -> Vector Text -> Type
+ Data.Avro.Schema: Enum :: TypeName -> [TypeName] -> Maybe Text -> Vector Text -> Schema
- Data.Avro.Schema: Field :: Text -> [Text] -> Maybe Text -> Maybe Order -> Type -> Maybe (Value Type) -> Field
+ Data.Avro.Schema: Field :: Text -> [Text] -> Maybe Text -> Maybe Order -> Schema -> Maybe (Value Schema) -> Field
- Data.Avro.Schema: Fixed :: TypeName -> [TypeName] -> Int -> Type
+ Data.Avro.Schema: Fixed :: TypeName -> [TypeName] -> Int -> Schema
- Data.Avro.Schema: Float :: Type
+ Data.Avro.Schema: Float :: Schema
- Data.Avro.Schema: Int :: Type
+ Data.Avro.Schema: Int :: Schema
- Data.Avro.Schema: Long :: Type
+ Data.Avro.Schema: Long :: Schema
- Data.Avro.Schema: Map :: Type -> Type
+ Data.Avro.Schema: Map :: Schema -> Schema
- Data.Avro.Schema: NamedType :: TypeName -> Type
+ Data.Avro.Schema: NamedType :: TypeName -> Schema
- Data.Avro.Schema: Null :: Type
+ Data.Avro.Schema: Null :: Schema
- Data.Avro.Schema: Record :: TypeName -> [TypeName] -> Maybe Text -> Maybe Order -> [Field] -> Type
+ Data.Avro.Schema: Record :: TypeName -> [TypeName] -> Maybe Text -> Maybe Order -> [Field] -> Schema
- Data.Avro.Schema: String :: Type
+ Data.Avro.Schema: String :: Schema
- Data.Avro.Schema: Union :: Vector Type -> Type
+ Data.Avro.Schema: Union :: Vector Schema -> Schema
- Data.Avro.Schema: [aliases] :: Type -> [TypeName]
+ Data.Avro.Schema: [aliases] :: Schema -> [TypeName]
- Data.Avro.Schema: [doc] :: Type -> Maybe Text
+ Data.Avro.Schema: [doc] :: Schema -> Maybe Text
- Data.Avro.Schema: [fields] :: Type -> [Field]
+ Data.Avro.Schema: [fields] :: Schema -> [Field]
- Data.Avro.Schema: [fldDefault] :: Field -> Maybe (Value Type)
+ Data.Avro.Schema: [fldDefault] :: Field -> Maybe (Value Schema)
- Data.Avro.Schema: [fldType] :: Field -> Type
+ Data.Avro.Schema: [fldType] :: Field -> Schema
- Data.Avro.Schema: [item] :: Type -> Type
+ Data.Avro.Schema: [item] :: Schema -> Schema
- Data.Avro.Schema: [name] :: Type -> TypeName
+ Data.Avro.Schema: [name] :: Schema -> TypeName
- Data.Avro.Schema: [options] :: Type -> Vector Type
+ Data.Avro.Schema: [options] :: Schema -> Vector Schema
- Data.Avro.Schema: [order] :: Type -> Maybe Order
+ Data.Avro.Schema: [order] :: Schema -> Maybe Order
- Data.Avro.Schema: [size] :: Type -> Int
+ Data.Avro.Schema: [size] :: Schema -> Int
- Data.Avro.Schema: [symbols] :: Type -> Vector Text
+ Data.Avro.Schema: [symbols] :: Schema -> Vector Text
- Data.Avro.Schema: [values] :: Type -> Type
+ Data.Avro.Schema: [values] :: Schema -> Schema
- Data.Avro.Schema: buildTypeEnvironment :: Applicative m => (TypeName -> m Type) -> Schema -> TypeName -> m Type
+ Data.Avro.Schema: buildTypeEnvironment :: Applicative m => (TypeName -> m Schema) -> Schema -> TypeName -> m Schema
- Data.Avro.Schema: extractBindings :: Type -> HashMap TypeName Type
+ Data.Avro.Schema: extractBindings :: Schema -> HashMap TypeName Schema
- Data.Avro.Schema: matches :: Type -> Type -> Bool
+ Data.Avro.Schema: matches :: Schema -> Schema -> Bool
- Data.Avro.Schema: mkEnum :: TypeName -> [TypeName] -> Maybe Text -> [Text] -> Type
+ Data.Avro.Schema: mkEnum :: TypeName -> [TypeName] -> Maybe Text -> [Text] -> Schema
- Data.Avro.Schema: mkUnion :: NonEmpty Type -> Type
+ Data.Avro.Schema: mkUnion :: NonEmpty Schema -> Schema
- Data.Avro.Schema: overlay :: Type -> Type -> Type
+ Data.Avro.Schema: overlay :: Schema -> Schema -> Schema
- Data.Avro.Schema: parseAvroJSON :: (Type -> Value -> Result (Value Type)) -> (TypeName -> Maybe Type) -> Type -> Value -> Result (Value Type)
+ Data.Avro.Schema: parseAvroJSON :: (Schema -> Value -> Result (Value Schema)) -> (TypeName -> Maybe Schema) -> Schema -> Value -> Result (Value Schema)
- Data.Avro.Schema: subdefinition :: Type -> Text -> Maybe Type
+ Data.Avro.Schema: subdefinition :: Schema -> Text -> Maybe Schema
- Data.Avro.Schema: typeName :: Type -> Text
+ Data.Avro.Schema: typeName :: Schema -> Text
- Data.Avro.ToAvro: (.=) :: ToAvro a => Text -> a -> (Text, Value Type)
+ Data.Avro.ToAvro: (.=) :: ToAvro a => Text -> a -> (Text, Value Schema)
- Data.Avro.ToAvro: toAvro :: ToAvro a => a -> Value Type
+ Data.Avro.ToAvro: toAvro :: ToAvro a => a -> Value Schema

Files

avro.cabal view
@@ -1,39 +1,38 @@-cabal-version:  2.2+cabal-version: 2.2 -name:           avro-version:        0.4.5.4-synopsis:       Avro serialization support for Haskell-description:    Avro serialization and deserialization support for Haskell-category:       Data-homepage:       https://github.com/haskell-works/avro#readme-bug-reports:    https://github.com/haskell-works/avro/issues-author:         Thomas M. DuBuisson-maintainer:     Alexey Raga <alexey.raga@gmail.com>-license:        BSD-3-Clause-license-file:   LICENSE-build-type:     Simple-extra-source-files:-    README.md-    ChangeLog.md-    test/data/enums.avsc-    test/data/internal-bindings.avsc-    test/data/karma.avsc-    test/data/logical.avsc-    test/data/maybe.avsc-    test/data/record.avsc-    test/data/reused.avsc-    test/data/small.avsc-    test/data/unions-no-namespace.avsc-    test/data/unions.avsc-    test/data/enums-object.json-    test/data/namespace-inference.json-    test/data/null-namespace.json-    test/data/unions-object-a.json-    test/data/unions-object-b.json-    test/data/overlay/composite.avsc-    test/data/overlay/expectation.avsc-    test/data/overlay/primitives.avsc-    test/data/fixed-types.avsc+name:                   avro+version:                0.4.6.0+synopsis:               Avro serialization support for Haskell+description:            Avro serialization and deserialization support for Haskell+category:               Data+homepage:               https://github.com/haskell-works/avro#readme+bug-reports:            https://github.com/haskell-works/avro/issues+author:                 Thomas M. DuBuisson+maintainer:             Alexey Raga <alexey.raga@gmail.com>+license:                BSD-3-Clause+license-file:           LICENSE+build-type:             Simple+extra-source-files:     README.md+                        ChangeLog.md+                        test/data/enums.avsc+                        test/data/internal-bindings.avsc+                        test/data/karma.avsc+                        test/data/logical.avsc+                        test/data/maybe.avsc+                        test/data/record.avsc+                        test/data/reused.avsc+                        test/data/small.avsc+                        test/data/unions-no-namespace.avsc+                        test/data/unions.avsc+                        test/data/enums-object.json+                        test/data/namespace-inference.json+                        test/data/null-namespace.json+                        test/data/unions-object-a.json+                        test/data/unions-object-b.json+                        test/data/overlay/composite.avsc+                        test/data/overlay/expectation.avsc+                        test/data/overlay/primitives.avsc+                        test/data/fixed-types.avsc  source-repository head   type: git@@ -62,6 +61,8 @@ common data-binary-ieee754      { build-depends: data-binary-ieee754                                } common deepseq                  { build-depends: deepseq                                            } common directory                { build-depends: directory                                          }+common doctest                  { build-depends: doctest                  >= 0.16.2     && < 0.17   }+common doctest-discover         { build-depends: doctest-discover         >= 0.2        && < 0.3    } common extra                    { build-depends: extra                                              } common fail                     { build-depends: fail                                               } common gauge                    { build-depends: gauge                                              }@@ -70,7 +71,6 @@ common lens                     { build-depends: lens                                               } common lens-aeson               { build-depends: lens-aeson                                         } common mtl                      { build-depends: mtl                                                }-common pure-zlib                { build-depends: pure-zlib                                          } common QuickCheck               { build-depends: QuickCheck                                         } common random                   { build-depends: random                                             } common raw-strings-qq           { build-depends: raw-strings-qq                                     }@@ -85,167 +85,174 @@ common zlib                     { build-depends: zlib                                               }  common config-  default-language: Haskell2010+  default-language:     Haskell2010   if flag(templatehaskell)-    other-extensions: TemplateHaskell-    build-depends:-        template-haskell >=2.4+    other-extensions:   TemplateHaskell+    build-depends:      template-haskell >=2.4   if flag(dev)-    ghc-options: -Wall -Werror+    ghc-options:        -Wall -Werror  library-  import:   base-          , aeson-          , array-          , base16-bytestring-          , bifunctors-          , binary-          , bytestring-          , containers-          , config-          , data-binary-ieee754-          , deepseq-          , fail-          , hashable-          , mtl-          , scientific-          , semigroups-          , tagged-          , text-          , tf-random-          , unordered-containers-          , vector-          , zlib-  exposed-modules:-      Data.Avro-      Data.Avro.Codec-      Data.Avro.Decode-      Data.Avro.Decode.Get-      Data.Avro.Decode.Lazy-      Data.Avro.Decode.Lazy.Convert-      Data.Avro.Decode.Lazy.Deconflict-      Data.Avro.Decode.Lazy.FromLazyAvro-      Data.Avro.Decode.Lazy.LazyValue-      Data.Avro.Decode.Strict-      Data.Avro.Decode.Strict.Internal-      Data.Avro.DecodeRaw-      Data.Avro.Deconflict-      Data.Avro.Deriving-      Data.Avro.Deriving.Lift-      Data.Avro.Deriving.NormSchema-      Data.Avro.EitherN-      Data.Avro.Encode-      Data.Avro.EncodeRaw-      Data.Avro.FromAvro-      Data.Avro.HasAvroSchema-      Data.Avro.JSON-      Data.Avro.Schema-      Data.Avro.ToAvro-      Data.Avro.Types-      Data.Avro.Types.Value-      Data.Avro.Zag-      Data.Avro.Zig-  hs-source-dirs: src-  other-extensions: OverloadedStrings+  import:               base+                      , aeson+                      , array+                      , base16-bytestring+                      , bifunctors+                      , binary+                      , bytestring+                      , containers+                      , config+                      , data-binary-ieee754+                      , deepseq+                      , fail+                      , hashable+                      , mtl+                      , scientific+                      , semigroups+                      , tagged+                      , text+                      , tf-random+                      , unordered-containers+                      , vector+                      , zlib+  exposed-modules:      Data.Avro+                        Data.Avro.Codec+                        Data.Avro.Decode+                        Data.Avro.Decode.Get+                        Data.Avro.Decode.Lazy+                        Data.Avro.Decode.Lazy.Convert+                        Data.Avro.Decode.Lazy.Deconflict+                        Data.Avro.Decode.Lazy.FromLazyAvro+                        Data.Avro.Decode.Lazy.LazyValue+                        Data.Avro.Decode.Strict+                        Data.Avro.Decode.Strict.Internal+                        Data.Avro.DecodeRaw+                        Data.Avro.Deconflict+                        Data.Avro.Deriving+                        Data.Avro.Deriving.Lift+                        Data.Avro.Deriving.NormSchema+                        Data.Avro.EitherN+                        Data.Avro.Encode+                        Data.Avro.EncodeRaw+                        Data.Avro.FromAvro+                        Data.Avro.HasAvroSchema+                        Data.Avro.JSON+                        Data.Avro.Schema+                        Data.Avro.ToAvro+                        Data.Avro.Types+                        Data.Avro.Types.Value+                        Data.Avro.Zag+                        Data.Avro.Zig+  hs-source-dirs:       src+  other-extensions:     OverloadedStrings  test-suite test-  import:   base-          , aeson-          , array-          , avro-          , base16-bytestring-          , bifunctors-          , binary-          , bytestring-          , containers-          , directory-          , extra-          , fail-          , hashable-          , hspec-          , lens-          , lens-aeson-          , mtl-          , pure-zlib-          , QuickCheck-          , raw-strings-qq-          , scientific-          , semigroups-          , tagged-          , text-          , tf-random-          , transformers-          , unordered-containers-          , vector-  type: exitcode-stdio-1.0-  ghc-options: -threaded-  default-language: Haskell2010-  main-is: Spec.hs-  build-tool-depends: hspec-discover:hspec-discover+  import:               base+                      , aeson+                      , array+                      , avro+                      , base16-bytestring+                      , bifunctors+                      , binary+                      , bytestring+                      , containers+                      , directory+                      , extra+                      , fail+                      , hashable+                      , hspec+                      , lens+                      , lens-aeson+                      , mtl+                      , zlib+                      , QuickCheck+                      , raw-strings-qq+                      , scientific+                      , semigroups+                      , tagged+                      , text+                      , tf-random+                      , transformers+                      , unordered-containers+                      , vector+  type:                 exitcode-stdio-1.0+  ghc-options:          -threaded+  default-language:     Haskell2010+  main-is:              Spec.hs+  build-tool-depends:   hspec-discover:hspec-discover   other-modules:-      Avro.Codec.ArraySpec-      Avro.Codec.BoolSpec-      Avro.Codec.CodecRawSpec-      Avro.Codec.DoubleSpec-      Avro.Codec.FloatSpec-      Avro.Codec.Int64Spec-      Avro.Codec.MaybeSpec-      Avro.Codec.NestedSpec-      Avro.Codec.TextSpec-      Avro.Codec.ZigZagSpec-      Avro.Decode.Lazy.ContainerSpec-      Avro.Decode.Lazy.RawBlocksSpec-      Avro.Decode.Lazy.RawValuesSpec-      Avro.Decode.Lazy.ValuesSpec-      Avro.Deconflict.A.Reader-      Avro.Deconflict.A.Writer-      Avro.Deconflict.B.Reader-      Avro.Deconflict.B.Writer-      Avro.Deconflict.C.Reader-      Avro.Deconflict.C.Writer-      Avro.DeconflictSpec-      Avro.DefaultsSpec-      Avro.EncodeRawSpec-      Avro.JSONSpec-      Avro.NamespaceSpec-      Avro.NormSchemaSpec-      Avro.ReuseFixedSpec-      Avro.SchemaSpec-      Avro.THEncodeContainerSpec-      Avro.THEnumSpec-      Avro.THLogicalTypeSpec-      Avro.THReusedSpec-      Avro.THSimpleSpec-      Avro.THUnionSpec-      Avro.ToAvroSpec-      DecodeContainer-      Example1-      Paths_avro-  autogen-modules:    Paths_avro-  hs-source-dirs:     test-+                        Avro.Codec.ArraySpec+                        Avro.Codec.BoolSpec+                        Avro.Codec.CodecRawSpec+                        Avro.Codec.DoubleSpec+                        Avro.Codec.FloatSpec+                        Avro.Codec.Int64Spec+                        Avro.Codec.MaybeSpec+                        Avro.Codec.NestedSpec+                        Avro.Codec.TextSpec+                        Avro.Codec.ZigZagSpec+                        Avro.Decode.Lazy.ContainerSpec+                        Avro.Decode.Lazy.RawBlocksSpec+                        Avro.Decode.Lazy.RawValuesSpec+                        Avro.Decode.Lazy.ValuesSpec+                        Avro.Deconflict.A.Reader+                        Avro.Deconflict.A.Writer+                        Avro.Deconflict.B.Reader+                        Avro.Deconflict.B.Writer+                        Avro.Deconflict.C.Reader+                        Avro.Deconflict.C.Writer+                        Avro.DeconflictSpec+                        Avro.DefaultsSpec+                        Avro.EncodeRawSpec+                        Avro.JSONSpec+                        Avro.NamespaceSpec+                        Avro.NormSchemaSpec+                        Avro.ReuseFixedSpec+                        Avro.SchemaSpec+                        Avro.THEncodeContainerSpec+                        Avro.THEnumSpec+                        Avro.THLogicalTypeSpec+                        Avro.THReusedSpec+                        Avro.THSimpleSpec+                        Avro.THUnionSpec+                        Avro.ToAvroSpec+                        DecodeContainer+                        Example1+                        Paths_avro+  autogen-modules:      Paths_avro+  hs-source-dirs:       test  benchmark bench-time-  import:   base, config-          , avro-          , aeson-          , bytestring-          , containers-          , gauge-          , hashable-          , mtl-          , random-          , raw-strings-qq-          , text-          , transformers-          , unordered-containers-          , vector-  default-language: Haskell2010-  type: exitcode-stdio-1.0-  main-is: Main.hs-  other-modules:-    Bench.Deconflict-    Bench.Deconflict.Reader-    Bench.Deconflict.Writer-    Bench.Time-  hs-source-dirs: bench+  import:               base, config+                      , avro+                      , aeson+                      , bytestring+                      , containers+                      , gauge+                      , hashable+                      , mtl+                      , random+                      , raw-strings-qq+                      , text+                      , transformers+                      , unordered-containers+                      , vector+  default-language:     Haskell2010+  type:                 exitcode-stdio-1.0+  main-is:              Main.hs+  other-modules:        Bench.Deconflict+                        Bench.Deconflict.Reader+                        Bench.Deconflict.Writer+                        Bench.Time+  hs-source-dirs:       bench++test-suite doctest+  import:               base, config+                      , avro+                      , doctest+                      , doctest-discover+  type:                 exitcode-stdio-1.0+  ghc-options:          -threaded+  main-is:              DoctestDriver.hs+  HS-Source-Dirs:       doctest+  build-tool-depends:   doctest-discover:doctest-discover
+ doctest/DoctestDriver.hs view
@@ -0,0 +1,12 @@+{-# LANGUAGE CPP #-}++#if MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)+{-# OPTIONS_GHC -F -pgmF doctest-discover #-}+#else+module Main where++import qualified System.IO as IO++main :: IO ()+main = IO.putStrLn "WARNING: doctest will not run on GHC versions earlier than 8.4.4"+#endif
src/Data/Avro.hs view
@@ -102,7 +102,7 @@ -- | Decode a lazy bytestring using a 'Schema' of the return type. decode :: forall a. FromAvro a => ByteString -> Result a decode bytes =-  case D.decodeAvro (untag (schema :: Tagged a Type)) bytes of+  case D.decodeAvro (untag (schema :: Tagged a Schema)) bytes of       Right val -> fromAvro val       Left err  -> Error err @@ -189,14 +189,14 @@                                  G.bytesRead        G.getLazyByteString (end-start) -record :: Foldable f => Type -> f (Text,T.Value Type) -> T.Value Type+record :: Foldable f => Schema -> f (Text,T.Value Schema) -> T.Value Schema record ty = T.Record ty . HashMap.fromList . toList -fixed :: Type -> B.ByteString -> T.Value Type+fixed :: Schema -> B.ByteString -> T.Value Schema fixed = T.Fixed -- @enumToAvro val@ will generate an Avro encoded value of enum suitable -- for serialization ('encode').--- enumToAvro :: (Show a, Enum a, Bounded a, Generic a) => a -> T.Value Type+-- enumToAvro :: (Show a, Enum a, Bounded a, Generic a) => a -> T.Value Schema -- enumToAvro e = T.Enum ty (show e) --  where --   ty = S.Enum nm Nothing [] Nothing (map (Text.pack . show) [minBound..maxBound])
src/Data/Avro/Decode.hs view
@@ -51,7 +51,7 @@ import           Data.Avro.Decode.Strict.Internal  -- | Decode bytes into a 'Value' as described by Schema.-decodeAvro :: Schema -> BL.ByteString -> Either String (T.Value Type)+decodeAvro :: Schema -> BL.ByteString -> Either String (T.Value Schema) decodeAvro sch = either (\(_,_,s) -> Left s) (\(_,_,a) -> Right a) . runGetOrFail (getAvroOf sch) {-# INLINABLE decodeAvro #-} @@ -61,7 +61,7 @@ -- -- "Data.Avro.Decode.Lazy" provides functions to decode Avro containers -- in a lazy, streaming fashion.-decodeContainer :: BL.ByteString -> Either String (Schema, [[T.Value Type]])+decodeContainer :: BL.ByteString -> Either String (Schema, [[T.Value Schema]]) decodeContainer = decodeContainerWith getAvroOf {-# INLINABLE decodeContainer #-} 
src/Data/Avro/Decode/Lazy.hs view
@@ -132,7 +132,7 @@     convertValue w r v = resultToEither $ fromLazyAvro (C.deconflictNoResolve w r v)  -- |Decode bytes into a 'Value' as described by Schema.-decodeAvro :: Schema -> BL.ByteString -> T.LazyValue Type+decodeAvro :: Schema -> BL.ByteString -> T.LazyValue Schema decodeAvro s = snd . getAvroOf s {-# INLINABLE decodeAvro #-} @@ -147,7 +147,7 @@ -- -- The "outer" error represents the error in opening the container itself -- (including problems like reading schemas embedded into the container.)-getContainerValues :: BL.ByteString -> Either String (Schema, [[T.LazyValue Type]])+getContainerValues :: BL.ByteString -> Either String (Schema, [[T.LazyValue Schema]]) getContainerValues = getContainerValuesWith getAvroOf {-# INLINABLE getContainerValues #-} @@ -210,9 +210,9 @@         (marker, _) | marker /= sync -> Left "Invalid marker, does not match sync bytes."         (_, rest)                    -> Right rest -getContainerValuesWith :: (Schema -> BL.ByteString -> (BL.ByteString, T.LazyValue Type))+getContainerValuesWith :: (Schema -> BL.ByteString -> (BL.ByteString, T.LazyValue Schema))                  -> BL.ByteString-                 -> Either String (Schema, [[T.LazyValue Type]])+                 -> Either String (Schema, [[T.LazyValue Schema]]) getContainerValuesWith schemaToGet bs =   case decodeRawBlocks bs of     Left err            -> Left err@@ -225,7 +225,7 @@         let (_, vs) = consumeN (fromIntegral nObj) getValue bytes         in vs -decodeGet :: GetAvro a => (a -> T.LazyValue Type) -> BL.ByteString -> (BL.ByteString, T.LazyValue Type)+decodeGet :: GetAvro a => (a -> T.LazyValue Schema) -> BL.ByteString -> (BL.ByteString, T.LazyValue Schema) decodeGet f bs =   let res = runGetOrFail (f <$> getAvro) bs   in either (\(rest,_,s) -> (rest, T.Error s)) (\(rest,_,a) -> (rest, a)) res@@ -251,7 +251,7 @@ -- 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' :: BL.ByteString -> Either String (Schema, [Either String (TypesStrict.Value S.Type, BL.ByteString)])+getContainerValuesBytes' :: BL.ByteString -> Either String (Schema, [Either String (TypesStrict.Value S.Schema, BL.ByteString)]) getContainerValuesBytes' =   extractContainerValues readBytes   where@@ -285,13 +285,13 @@       in (r, b:bs) {-# INLINE consumeN #-} -getAvroOf :: Schema -> BL.ByteString -> (BL.ByteString, T.LazyValue Type)+getAvroOf :: Schema -> BL.ByteString -> (BL.ByteString, T.LazyValue Schema) getAvroOf ty0 bs = go ty0 bs   where   env = S.buildTypeEnvironment envFail ty0   envFail t = fail $ "Named type not in schema: " <> show t -  go :: Type -> BL.ByteString -> (BL.ByteString, T.LazyValue Type)+  go :: Schema -> BL.ByteString -> (BL.ByteString, T.LazyValue Schema)   go ty bs =     case ty of       Null    -> (bs, T.Null)@@ -343,8 +343,8 @@ {-# INLINE getKVPair #-}  getKVPairs :: BL.ByteString-           -> (BL.ByteString -> (BL.ByteString, T.LazyValue Type))-           -> (BL.ByteString, [[(Text, T.LazyValue Type)]])+           -> (BL.ByteString -> (BL.ByteString, T.LazyValue Schema))+           -> (BL.ByteString, [[(Text, T.LazyValue Schema)]]) getKVPairs bs getElement =   case runGetOrFail (abs <$> getLong) bs of     Left (bs', _, err) -> (bs', [[("", T.Error err)]])@@ -357,8 +357,8 @@   getElements :: BL.ByteString-            -> (BL.ByteString -> (BL.ByteString, T.LazyValue Type))-            -> (BL.ByteString, [[T.LazyValue Type]])+            -> (BL.ByteString -> (BL.ByteString, T.LazyValue Schema))+            -> (BL.ByteString, [[T.LazyValue Schema]]) getElements bs getElement  =   case runGetOrFail (abs <$> getLong) bs of     Left (bs', _, err) -> (bs', [[T.Error err]])
src/Data/Avro/Decode/Lazy/Deconflict.hs view
@@ -31,8 +31,8 @@ -- To avoid it use 'deconflictNoResolve' when possible. deconflict :: Schema        -- ^ Writer schema            -> Schema        -- ^ Reader schema-           -> T.LazyValue Type-           -> T.LazyValue Type+           -> T.LazyValue Schema+           -> T.LazyValue Schema deconflict writerSchema readerSchema =   deconflictNoResolve (S.expandNamedTypes writerSchema) (S.expandNamedTypes readerSchema) @@ -48,17 +48,17 @@ -- to be used in 'deconflictNoResolve'. deconflictNoResolve :: Schema         -- ^ Writer schema                     -> Schema         -- ^ Reader schema-                    -> T.LazyValue Type-                    -> T.LazyValue Type+                    -> T.LazyValue Schema+                    -> T.LazyValue Schema deconflictNoResolve writerSchema readerSchema =   deconflictValue writerSchema readerSchema -deconflictValue :: Type -> Type -> T.LazyValue Type -> T.LazyValue Type+deconflictValue :: Schema -> Schema -> T.LazyValue Schema -> T.LazyValue Schema deconflictValue writerSchema readerSchema v   | writerSchema == readerSchema    = v   | otherwise = go writerSchema readerSchema v   where-    go :: Type -> Type -> T.LazyValue Type -> T.LazyValue Type+    go :: Schema -> Schema -> T.LazyValue Schema -> T.LazyValue Schema     go _ _ val@(T.Error _) = val     go (S.Array aTy) (S.Array bTy) (T.Array vec) =         T.Array $ fmap (go aTy bTy) vec@@ -89,7 +89,7 @@         _                            -> T.Error $ "Can not resolve differing writer and reader schemas: " ++ show (eTy, dTy)  -- The writer's symbol must be present in the reader's enum-deconflictEnum :: Type -> Type -> T.LazyValue Type -> T.LazyValue Type+deconflictEnum :: Schema -> Schema -> T.LazyValue Schema -> T.LazyValue Schema deconflictEnum e d val@(T.Enum _ _ _txt) = val   -- --  | txt `elem` symbols d = Right val   -- --  | otherwise = Left "Decoded enum does not appear in reader's symbol list."@@ -104,7 +104,7 @@     Nothing    -> T.Error $ "Incorrect payload: union " <> (show . Foldable.toList $ typeName <$> schemas) <> " does not contain schema " <> Text.unpack (typeName schema)     Just found -> f found -deconflictReaderUnion :: Type -> Vector Type -> T.LazyValue Type -> T.LazyValue Type+deconflictReaderUnion :: Schema -> Vector Schema -> T.LazyValue Schema -> T.LazyValue Schema deconflictReaderUnion valueType unionTypes val =   let hdl [] = T.Error $ "No corresponding union value for " <> Text.unpack (typeName valueType)       hdl (d:rest) =@@ -113,7 +113,7 @@               v         -> T.Union unionTypes d v   in hdl (V.toList unionTypes) -deconflictRecord :: Type -> Type -> T.LazyValue Type -> T.LazyValue Type+deconflictRecord :: Schema -> Schema -> T.LazyValue Schema -> T.LazyValue Schema deconflictRecord writerSchema readerSchema (T.Record ty fldVals)  =   T.Record readerSchema . HashMap.fromList $ fmap (deconflictFields fldVals (fields writerSchema)) (fields readerSchema) @@ -123,7 +123,7 @@ --  3) If there is no default, fail. -- -- XXX: Consider aliases in the writer schema, use those to retry on failed lookup.-deconflictFields :: HashMap Text (T.LazyValue Type) -> [Field] -> Field -> (Text,T.LazyValue Type)+deconflictFields :: HashMap Text (T.LazyValue Schema) -> [Field] -> Field -> (Text,T.LazyValue Schema) deconflictFields hm writerFields readerField =   let     mbWriterField = findField readerField writerFields
src/Data/Avro/Decode/Lazy/FromLazyAvro.hs view
@@ -35,10 +35,10 @@ -- without converting to strict `Value` and then 'FromAvro' -- can be very beneficial from the performance point of view. class HasAvroSchema a => FromLazyAvro a where-  fromLazyAvro :: LazyValue Type -> Result a+  fromLazyAvro :: LazyValue Schema -> Result a  --  | Same as '(.:)' but works on `LazyValue`.-(.~:) :: FromLazyAvro a => HashMap.HashMap Text (LazyValue Type) -> Text -> Result a+(.~:) :: FromLazyAvro a => HashMap.HashMap Text (LazyValue Schema) -> Text -> Result a (.~:) obj key =   case HashMap.lookup key obj of     Nothing -> fail $ "Requested field not available: " <> show key@@ -49,8 +49,8 @@     | S.matches branch schemaA = Left  <$> fromLazyAvro x     | S.matches branch schemaB = Right <$> fromLazyAvro x     | otherwise              = badValue e "Either"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema   fromLazyAvro x = badValue x "Either"  instance FromLazyAvro Bool where
src/Data/Avro/Decode/Strict/Internal.hs view
@@ -39,13 +39,13 @@ import           Data.Avro.Zag  {-# INLINABLE getAvroOf #-}-getAvroOf :: Schema -> Get (T.Value Type)+getAvroOf :: Schema -> Get (T.Value Schema) getAvroOf ty0 = go ty0  where  env = S.buildTypeEnvironment envFail ty0  envFail t = fail $ "Named type not in schema: " <> show t - go :: Type -> Get (T.Value Type)+ go :: Schema -> Get (T.Value Schema)  go ty =   case ty of     Null    -> return T.Null@@ -77,7 +77,7 @@           Just t  -> T.Union ts t <$> go t     Fixed {..} -> T.Fixed ty <$> G.getByteString (fromIntegral size) - getKVBlocks :: Type -> Get [[(Text,T.Value Type)]]+ getKVBlocks :: Schema -> Get [[(Text,T.Value Schema)]]  getKVBlocks t =   do blockLength <- abs <$> getLong      if blockLength == 0@@ -86,7 +86,7 @@               (vs:) <$> getKVBlocks t  {-# INLINE getKVBlocks #-} - getBlocksOf :: Type -> Get [[T.Value Type]]+ getBlocksOf :: Schema -> Get [[T.Value Schema]]  getBlocksOf t =   do blockLength <- abs <$> getLong      if blockLength == 0
src/Data/Avro/Deconflict.hs view
@@ -31,8 +31,8 @@ -- To avoid it use 'deconflictNoResolve' when possible. deconflict :: Schema        -- ^ Writer schema            -> Schema        -- ^ Reader schema-           -> T.Value Type-           -> Either String (T.Value Type)+           -> T.Value Schema+           -> Either String (T.Value Schema) deconflict writerSchema readerSchema =   deconflictNoResolve (S.expandNamedTypes writerSchema) (S.expandNamedTypes readerSchema) @@ -48,20 +48,20 @@ -- to be used in 'deconflictNoResolve'. deconflictNoResolve :: Schema         -- ^ Writer schema                     -> Schema         -- ^ Reader schema-                    -> T.Value Type-                    -> Either String (T.Value Type)+                    -> T.Value Schema+                    -> Either String (T.Value Schema) deconflictNoResolve writerSchema readerSchema =   deconflictValue writerSchema readerSchema  deconflictValue :: Schema               -> Schema-              -> T.Value Type-              -> Either String (T.Value Type)+              -> T.Value Schema+              -> Either String (T.Value Schema) deconflictValue writerSchema readerSchema v   | writerSchema == readerSchema    = Right v   | otherwise = go writerSchema readerSchema v   where-  go :: Type -> Type -> T.Value Type -> Either String (T.Value Type)+  go :: Schema -> Schema -> T.Value Schema -> Either String (T.Value Schema)   go (S.Array aTy) (S.Array bTy) (T.Array vec) =        T.Array <$> mapM (go aTy bTy) vec   go (S.Map aTy) (S.Map bTy) (T.Map mp)    =@@ -91,7 +91,7 @@       _                            -> Left $ "Can not resolve differing writer and reader schemas: " ++ show (eTy, dTy)  -- The writer's symbol must be present in the reader's enum-deconflictEnum :: Type -> Type -> T.Value Type -> Either String (T.Value Type)+deconflictEnum :: Schema -> Schema -> T.Value Schema -> Either String (T.Value Schema) deconflictEnum e d val@(T.Enum _ _ _txt) = Right val   -- --  | txt `elem` symbols d = Right val   -- --  | otherwise = Left "Decoded enum does not appear in reader's symbol list."@@ -106,7 +106,7 @@     Nothing    -> Left $ "Incorrect payload: union " <> (show . Foldable.toList $ typeName <$> schemas) <> " does not contain schema " <> Text.unpack (typeName schema)     Just found -> f found -deconflictReaderUnion :: Type -> Vector Type -> T.Value Type -> Either String (T.Value Type)+deconflictReaderUnion :: Schema -> Vector Schema -> T.Value Schema -> Either String (T.Value Schema) deconflictReaderUnion valueSchema unionTypes val =     let hdl [] = Left "Impossible: empty non-empty list."         hdl (d:rest) =@@ -115,7 +115,7 @@                 Left _  -> hdl rest     in hdl (V.toList unionTypes) -deconflictRecord :: Type -> Type -> T.Value Type -> Either String (T.Value Type)+deconflictRecord :: Schema -> Schema -> T.Value Schema -> Either String (T.Value Schema) deconflictRecord writerSchema readerSchema (T.Record ty fldVals)  =   T.Record readerSchema . HashMap.fromList <$> mapM (deconflictFields fldVals (fields writerSchema)) (fields readerSchema) @@ -125,7 +125,7 @@ --  3) If there is no default, fail. -- -- XXX: Consider aliases in the writer schema, use those to retry on failed lookup.-deconflictFields :: HashMap Text (T.Value Type) -> [Field] -> Field -> Either String (Text,T.Value Type)+deconflictFields :: HashMap Text (T.Value Schema) -> [Field] -> Field -> Either String (Text,T.Value Schema) deconflictFields hm writerFields readerField =   let     mbWriterField = findField readerField writerFields
src/Data/Avro/Deriving.hs view
@@ -488,7 +488,7 @@   sequenceA [genNewtype dname] genType _ _ = pure [] -mkFieldTypeName :: NamespaceBehavior -> S.Type -> Q TH.Type+mkFieldTypeName :: NamespaceBehavior -> S.Schema -> Q TH.Type mkFieldTypeName namespaceBehavior = \case   S.Boolean          -> [t| Bool |]   S.Long             -> [t| Int64 |]
src/Data/Avro/Deriving/Lift.hs view
@@ -34,4 +34,4 @@ deriving instance Lift Schema.Field deriving instance Lift Schema.Order deriving instance Lift Schema.TypeName-deriving instance Lift Schema.Type+deriving instance Lift Schema.Schema
src/Data/Avro/Deriving/NormSchema.hs view
@@ -28,7 +28,7 @@     rawRecs = getTypes s     state = M.fromList rawRecs -getTypes :: Type -> [(TypeName, Type)]+getTypes :: Schema -> [(TypeName, Schema)] getTypes rec = case rec of   r@Record{name, fields} -> (name,r) : (fields >>= (getTypes . fldType))   Array t                -> getTypes t
src/Data/Avro/EitherN.hs view
@@ -114,24 +114,24 @@   bitraverse _ g (E5_5 a) = E5_5 <$> g a  instance (HasAvroSchema a, HasAvroSchema b, HasAvroSchema c) => HasAvroSchema (Either3 a b c) where-  schema = Tagged $ mkUnion (untag (schema :: Tagged a Type) :| [-                             untag (schema :: Tagged b Type),-                             untag (schema :: Tagged c Type)+  schema = Tagged $ mkUnion (untag (schema :: Tagged a Schema) :| [+                             untag (schema :: Tagged b Schema),+                             untag (schema :: Tagged c Schema)                             ])  instance (HasAvroSchema a, HasAvroSchema b, HasAvroSchema c, HasAvroSchema d) => HasAvroSchema (Either4 a b c d) where-  schema = Tagged $ mkUnion (untag (schema :: Tagged a Type) :| [-                             untag (schema :: Tagged b Type),-                             untag (schema :: Tagged c Type),-                             untag (schema :: Tagged d Type)+  schema = Tagged $ mkUnion (untag (schema :: Tagged a Schema) :| [+                             untag (schema :: Tagged b Schema),+                             untag (schema :: Tagged c Schema),+                             untag (schema :: Tagged d Schema)                             ])  instance (HasAvroSchema a, HasAvroSchema b, HasAvroSchema c, HasAvroSchema d, HasAvroSchema e) => HasAvroSchema (Either5 a b c d e) where-  schema = Tagged $ mkUnion (untag (schema :: Tagged a Type) :| [-                             untag (schema :: Tagged b Type),-                             untag (schema :: Tagged c Type),-                             untag (schema :: Tagged d Type),-                             untag (schema :: Tagged e Type)+  schema = Tagged $ mkUnion (untag (schema :: Tagged a Schema) :| [+                             untag (schema :: Tagged b Schema),+                             untag (schema :: Tagged c Schema),+                             untag (schema :: Tagged d Schema),+                             untag (schema :: Tagged e Schema)                             ])  instance (FromAvro a, FromAvro b, FromAvro c) => FromAvro (Either3 a b c) where@@ -140,9 +140,9 @@     | matches branch schemaB = E3_2 <$> fromAvro x     | matches branch schemaC = E3_3 <$> fromAvro x     | otherwise              = badValue e "Either3"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema   fromAvro x = badValue x "Either3"  instance (FromAvro a, FromAvro b, FromAvro c, FromAvro d) => FromAvro (Either4 a b c d) where@@ -152,10 +152,10 @@     | matches branch schemaC = E4_3 <$> fromAvro x     | matches branch schemaD = E4_4 <$> fromAvro x     | otherwise              = badValue e "Either4"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type-          Tagged schemaD = schema :: Tagged d Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema+          Tagged schemaD = schema :: Tagged d Schema   fromAvro x = badValue x "Either4"  instance (FromAvro a, FromAvro b, FromAvro c, FromAvro d, FromAvro e) => FromAvro (Either5 a b c d e) where@@ -166,11 +166,11 @@     | matches branch schemaD = E5_4 <$> fromAvro x     | matches branch schemaE = E5_5 <$> fromAvro x     | otherwise              = badValue e "Either5"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type-          Tagged schemaD = schema :: Tagged d Type-          Tagged schemaE = schema :: Tagged e Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema+          Tagged schemaD = schema :: Tagged d Schema+          Tagged schemaE = schema :: Tagged e Schema   fromAvro x = badValue x "Either5"  instance (FromLazyAvro a, FromLazyAvro b, FromLazyAvro c) => FromLazyAvro (Either3 a b c) where@@ -179,9 +179,9 @@     | matches branch schemaB = E3_2 <$> fromLazyAvro x     | matches branch schemaC = E3_3 <$> fromLazyAvro x     | otherwise              = badValue e "Either3"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema   fromLazyAvro x = badValue x "Either3"  instance (FromLazyAvro a, FromLazyAvro b, FromLazyAvro c, FromLazyAvro d) => FromLazyAvro (Either4 a b c d) where@@ -191,10 +191,10 @@     | matches branch schemaC = E4_3 <$> fromLazyAvro x     | matches branch schemaD = E4_4 <$> fromLazyAvro x     | otherwise              = badValue e "Either4"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type-          Tagged schemaD = schema :: Tagged d Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema+          Tagged schemaD = schema :: Tagged d Schema   fromLazyAvro x = badValue x "Either4"  instance (FromLazyAvro a, FromLazyAvro b, FromLazyAvro c, FromLazyAvro d, FromLazyAvro e) => FromLazyAvro (Either5 a b c d e) where@@ -205,11 +205,11 @@     | matches branch schemaD = E5_4 <$> fromLazyAvro x     | matches branch schemaE = E5_5 <$> fromLazyAvro x     | otherwise              = badValue e "Either5"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type-          Tagged schemaC = schema :: Tagged c Type-          Tagged schemaD = schema :: Tagged d Type-          Tagged schemaE = schema :: Tagged e Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema+          Tagged schemaC = schema :: Tagged c Schema+          Tagged schemaD = schema :: Tagged d Schema+          Tagged schemaE = schema :: Tagged e Schema   fromLazyAvro x = badValue x "Either5"  instance (ToAvro a, ToAvro b, ToAvro c) => ToAvro (Either3 a b c) where
src/Data/Avro/Encode.hs view
@@ -164,13 +164,13 @@ getSchema :: forall a. EncodeAvro a => a -> Schema getSchema = snd . runAvro . avro -getType :: EncodeAvro a => Proxy a -> Type+getType :: EncodeAvro a => Proxy a -> Schema getType = getSchema . (asProxyTypeOf undefined) -- N.B. ^^^ Local knowledge that 'fst' won't be used, -- so the bottom of 'undefined' will not escape so long as schema creation -- remains lazy in the argument. -newtype AvroM = AvroM { runAvro :: (Builder,Type) }+newtype AvroM = AvroM { runAvro :: (Builder, Schema) }  class EncodeAvro a where   avro :: a -> AvroM@@ -277,7 +277,7 @@ -------------------------------------------------------------------------------- --  Common Intermediate Representation Encoding -instance EncodeAvro (T.Value Type) where+instance EncodeAvro (T.Value Schema) where   avro v =     case v of       T.Null      -> avro ()
src/Data/Avro/FromAvro.hs view
@@ -30,9 +30,9 @@ import           Data.Word  class HasAvroSchema a => FromAvro a where-  fromAvro :: Value Type -> Result a+  fromAvro :: Value Schema -> Result a -(.:) :: FromAvro a => HashMap.HashMap Text (Value Type) -> Text -> Result a+(.:) :: FromAvro a => HashMap.HashMap Text (Value Schema) -> Text -> Result a (.:) obj key =   case HashMap.lookup key obj of     Nothing -> fail $ "Requested field not available: " <> show key@@ -43,8 +43,8 @@     | S.matches branch schemaA = Left  <$> fromAvro x     | S.matches branch schemaB = Right <$> fromAvro x     | otherwise              = badValue e "Either"-    where Tagged schemaA = schema :: Tagged a Type-          Tagged schemaB = schema :: Tagged b Type+    where Tagged schemaA = schema :: Tagged a Schema+          Tagged schemaB = schema :: Tagged b Schema   fromAvro x = badValue x "Either"  instance FromAvro Bool where
src/Data/Avro/HasAvroSchema.hs view
@@ -27,9 +27,9 @@ import           Data.Word  class HasAvroSchema a where-  schema :: Tagged a Type+  schema :: Tagged a Schema -schemaOf :: (HasAvroSchema a) => a -> Type+schemaOf :: (HasAvroSchema a) => a -> Schema schemaOf = witness schema  instance HasAvroSchema Word8 where@@ -84,44 +84,44 @@   schema = Tagged S.Bytes  instance (HasAvroSchema a, HasAvroSchema b) => HasAvroSchema (Either a b) where-  schema = Tagged $ S.Union $ V.fromListN 2 [untag (schema :: Tagged a Type), untag (schema :: Tagged b Type)]+  schema = Tagged $ S.Union $ V.fromListN 2 [untag (schema :: Tagged a Schema), untag (schema :: Tagged b Schema)]  instance (HasAvroSchema a) => HasAvroSchema (Map.Map Text a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (HashMap.HashMap Text a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (Map.Map TL.Text a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (HashMap.HashMap TL.Text a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (Map.Map String a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (HashMap.HashMap String a) where-  schema = wrapTag S.Map (schema :: Tagged a Type)+  schema = wrapTag S.Map (schema :: Tagged a Schema)  instance (HasAvroSchema a) => HasAvroSchema (Maybe a) where-  schema = Tagged $ mkUnion (S.Null:| [untag (schema :: Tagged a Type)])+  schema = Tagged $ mkUnion (S.Null:| [untag (schema :: Tagged a Schema)])  instance (HasAvroSchema a) => HasAvroSchema [a] where-  schema = wrapTag S.Array (schema :: Tagged a Type)+  schema = wrapTag S.Array (schema :: Tagged a Schema)  instance (HasAvroSchema a, Ix i) => HasAvroSchema (Ar.Array i a) where-  schema = wrapTag S.Array (schema :: Tagged a Type)+  schema = wrapTag S.Array (schema :: Tagged a Schema)  instance HasAvroSchema a => HasAvroSchema (V.Vector a) where-  schema = wrapTag S.Array (schema :: Tagged a Type)+  schema = wrapTag S.Array (schema :: Tagged a Schema)  instance HasAvroSchema a => HasAvroSchema (U.Vector a) where-  schema = wrapTag S.Array (schema :: Tagged a Type)+  schema = wrapTag S.Array (schema :: Tagged a Schema)  instance HasAvroSchema a => HasAvroSchema (S.Set a) where-  schema = wrapTag S.Array (schema :: Tagged a Type)+  schema = wrapTag S.Array (schema :: Tagged a Schema) -wrapTag :: (Type -> Type) -> Tagged a Type -> Tagged b Type+wrapTag :: (Schema -> Schema) -> Tagged a Schema -> Tagged b Schema wrapTag f = Tagged . f . untag {-# INLINE wrapTag #-}
src/Data/Avro/Schema.hs view
@@ -20,7 +20,7 @@ module Data.Avro.Schema   (    -- * Schema description types-    Schema, Type(..)+    Schema(..), Type   , Field(..), Order(..)   , TypeName(..)   , renderFullname@@ -83,22 +83,13 @@  import GHC.Generics (Generic) --- | An Avro schema is either------ * A "JSON object in the form @{"type":"typeName" ...}@------ * A "JSON string, naming a defined type" (basic type without free variables)------ * A "JSON array, representing a union"------ N.B. It is possible to create a Haskell value (of 'Schema' type) that is+{-# DEPRECATED Type "Use Schema instead" #-}+type Type = Schema++-- | 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'.-type Schema = Type---- |Avro types are considered either primitive (string, int, etc) or--- complex/declared (structures, unions etc).-data Type+data Schema       =       -- Basic types         Null@@ -106,8 +97,8 @@       | Int   | Long       | Float | Double       | Bytes | String-      | Array { item :: Type }-      | Map   { values :: Type }+      | Array { item :: Schema }+      | Map   { values :: Schema }       | NamedType TypeName       -- Declared types       | Record { name    :: TypeName@@ -121,7 +112,7 @@              , doc     :: Maybe Text              , symbols :: V.Vector Text              }-      | Union { options     :: V.Vector Type+      | Union { options     :: V.Vector Schema               }       | Fixed { name    :: TypeName               , aliases :: [TypeName]@@ -129,7 +120,7 @@               }     deriving (Show, Generic, NFData) -instance Eq Type where+instance Eq Schema where   Null == Null = True   Boolean == Boolean = True   Int == Int = True@@ -162,13 +153,13 @@           -- ^ Optional documentation for the enum.        -> [Text]           -- ^ The symbols of the enum.-       -> Type+       -> Schema mkEnum name aliases doc symbols = Enum name aliases doc (V.fromList symbols)  -- | @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!-mkUnion :: NonEmpty Type -> Type+mkUnion :: NonEmpty Schema -> Schema mkUnion  = Union . V.fromList . NE.toList  -- | A named type in Avro has a name and, optionally, a namespace.@@ -281,7 +272,7 @@  -- |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+typeName :: Schema -> Text typeName bt =   case bt of     Null           -> "null"@@ -302,15 +293,15 @@                    , fldAliases :: [Text]                    , fldDoc     :: Maybe Text                    , fldOrder   :: Maybe Order-                   , fldType    :: Type-                   , fldDefault :: Maybe (Ty.Value Type)+                   , fldType    :: Schema+                   , fldDefault :: Maybe (Ty.Value Schema)                    }   deriving (Eq, Show, Generic, NFData)  data Order = Ascending | Descending | Ignore   deriving (Eq, Ord, Show, Generic, NFData) -instance FromJSON Type where+instance FromJSON Schema where   parseJSON = parseSchemaJSON Nothing  -- | A helper function that parses an Avro schema from JSON, resolving@@ -421,7 +412,7 @@     return $ Field name aliases doc order ty def   invalid    -> typeMismatch "Field" invalid -instance ToJSON Type where+instance ToJSON Schema where   toJSON = schemaToJSON Nothing  -- | Serializes a 'Schema' to JSON.@@ -493,7 +484,7 @@              , "aliases" .= fldAliases              ] -instance ToJSON (Ty.Value Type) where+instance ToJSON (Ty.Value Schema) where   toJSON av =     case av of       Ty.Null              -> A.Null@@ -568,7 +559,7 @@ -- | Field defaults are in the normal Avro JSON format except for -- unions. Default values for unions are specified as JSON encodings -- of the first type in the union.-parseFieldDefault :: (TypeName -> Maybe Type)+parseFieldDefault :: (TypeName -> Maybe Schema)                      -- ^ Lookup function for names defined in schema.                   -> Schema                      -- ^ The schema of the default value being parsed.@@ -580,7 +571,7 @@         defaultUnion _ _            = error "Impossible: not Union."  -- | Parse JSON-encoded avro data.-parseAvroJSON :: (Type -> A.Value -> Result (Ty.Value Type))+parseAvroJSON :: (Schema -> A.Value -> Result (Ty.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@@ -589,10 +580,10 @@                  -- 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 Type)-              -> Type+              -> (TypeName -> Maybe Schema)+              -> Schema               -> A.Value-              -> Result (Ty.Value Type)+              -> Result (Ty.Value Schema) parseAvroJSON union env (NamedType name) av =   case env name of     Nothing -> fail $ "Could not resolve type name for " <> T.unpack (renderFullname name)@@ -659,7 +650,7 @@ serializeBytes :: B.ByteString -> Text serializeBytes = T.pack . map (Char.chr . fromIntegral) . B.unpack -avroTypeMismatch :: Type -> Text -> Result a+avroTypeMismatch :: Schema -> Text -> Result a avroTypeMismatch expected actual =   fail $ "Could not resolve type '" <> T.unpack actual <> "' with expected type: " <> show expected @@ -700,13 +691,13 @@ -- 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)+                     => (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 Type)+                     -> (TypeName -> m Schema) buildTypeEnvironment failure from =     \ forTy -> case HashMap.lookup forTy env of                  Nothing  -> failure forTy@@ -719,7 +710,7 @@ -- -- 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+matches :: Schema -> Schema -> Bool matches n@NamedType{} t             = typeName n == typeName t matches t n@NamedType{}             = typeName t == typeName n matches (Array itemA) (Array itemB) = matches itemA itemB@@ -737,7 +728,7 @@ -- -- Types declared implicitly in record field definitions are also included. No distinction -- is made between aliases and normal names.-extractBindings :: Type -> HashMap.HashMap TypeName Type+extractBindings :: Schema -> HashMap.HashMap TypeName Schema extractBindings = \case   t@Record{..} ->     let withRecord = HashMap.fromList $ (name : aliases) `zip` repeat t@@ -775,7 +766,7 @@  -- | Merge two schemas to produce a third. -- Specifically, @overlay schema reference@ fills in 'NamedTypes' in 'schema' using any matching definitions from 'reference'.-overlay :: Type -> Type -> Type+overlay :: Schema -> Schema -> Schema overlay input supplement = overlayType input   where     overlayField f@Field{..}      = f { fldType = overlayType fldType }@@ -790,5 +781,5 @@     bindings              = extractBindings supplement  -- | Extract the named inner type definition as its own schema.-subdefinition :: Type -> Text -> Maybe Type+subdefinition :: Schema -> Text -> Maybe Schema subdefinition schema name = mkTypeName Nothing name Nothing `HashMap.lookup` extractBindings schema
src/Data/Avro/ToAvro.hs view
@@ -25,9 +25,9 @@ import           Data.Word  class HasAvroSchema a => ToAvro a where-  toAvro :: a -> T.Value Type+  toAvro :: a -> T.Value Schema -(.=)  :: ToAvro a => Text -> a -> (Text,T.Value Type)+(.=)  :: ToAvro a => Text -> a -> (Text,T.Value Schema) (.=) nm val = (nm,toAvro val)  instance ToAvro Bool where
test/Avro/Codec/DoubleSpec.hs view
@@ -1,12 +1,15 @@ {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -Wno-overflowed-literals #-}+ module Avro.Codec.DoubleSpec (spec) where -import           Data.Avro-import           Data.Avro.Schema-import           Data.Tagged-import           Test.Hspec+import Data.Avro+import Data.Avro.Schema+import Data.Tagged+import Test.Hspec+ import qualified Data.Avro.Types      as AT import qualified Data.ByteString.Lazy as BL import qualified Test.QuickCheck      as Q@@ -14,7 +17,7 @@ {-# ANN module ("HLint: ignore Redundant do"        :: String) #-}  newtype OnlyDouble = OnlyDouble-  {onlyDoubleValue :: Double+  { onlyDoubleValue :: Double   } deriving (Show, Eq)  onlyDoubleSchema :: Schema
test/Avro/Codec/FloatSpec.hs view
@@ -1,12 +1,15 @@ {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -Wno-overflowed-literals #-}+ module Avro.Codec.FloatSpec (spec) where -import           Data.Avro-import           Data.Avro.Schema-import           Data.Tagged-import           Test.Hspec+import Data.Avro+import Data.Avro.Schema+import Data.Tagged+import Test.Hspec+ import qualified Data.Avro.Types      as AT import qualified Data.ByteString.Lazy as BL import qualified Test.QuickCheck      as Q@@ -14,7 +17,7 @@ {-# ANN module ("HLint: ignore Redundant do"        :: String) #-}  newtype OnlyFloat = OnlyFloat-  {onlyFloatValue :: Float+  { onlyFloatValue :: Float   } deriving (Show, Eq)  onlyFloatSchema :: Schema
test/Avro/NormSchemaSpec.hs view
@@ -7,7 +7,7 @@  import           Data.Avro import           Data.Avro.Deriving-import           Data.Avro.Schema   (Type (..), fields, fldType, mkUnion)+import           Data.Avro.Schema   (Schema (..), fields, fldType, mkUnion) import           Data.List.NonEmpty (NonEmpty (..)) import qualified Data.Set           as S 
test/Avro/ReuseFixedSpec.hs view
@@ -8,7 +8,7 @@ import qualified Data.Aeson           as Aeson import           Data.Avro            as Avro import           Data.Avro.Deriving-import           Data.Avro.Schema     (Type (..), fields, fldType, mkUnion)+import           Data.Avro.Schema     (Schema (..), fields, fldType, mkUnion) import           Data.ByteString.Lazy as LBS import           Data.List.NonEmpty   (NonEmpty (..)) import qualified Data.Set             as S