binary 0.8.5.1 → 0.8.6.0
raw patch · 10 files changed
+491/−94 lines, 10 filesdep +generic-derivingdep −tardep ~Cabaldep ~QuickCheckPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: generic-deriving
Dependencies removed: tar
Dependency ranges changed: Cabal, QuickCheck
API changes (from Hackage documentation)
- Data.Binary.Put: instance Data.Semigroup.Semigroup (Data.Binary.Put.PutM ())
+ Data.Binary.Put: instance GHC.Base.Semigroup (Data.Binary.Put.PutM ())
- Data.Binary.Builder: data Builder :: *
+ Data.Binary.Builder: data Builder
Files
- benchmarks/Builder.hs +2/−0
- benchmarks/Cabal24.hs +360/−0
- benchmarks/GenericsBench.hs +1/−1
- benchmarks/GenericsBenchCache.hs +19/−68
- benchmarks/GenericsBenchTypes.hs +3/−16
- binary.cabal +78/−7
- changelog.md +6/−0
- src/Data/Binary/Class.hs +9/−0
- src/Data/Binary/Generic.hs +12/−1
- tests/QC.hs +1/−1
benchmarks/Builder.hs view
@@ -189,7 +189,9 @@ ------------------------------------------------------------------------ -- Utilities +#if !MIN_VERSION_base(4,11,0) infixr 6 <> (<>) :: Monoid m => m -> m -> m (<>) = mappend+#endif
+ benchmarks/Cabal24.hs view
@@ -0,0 +1,360 @@+{-# LANGUAGE DeriveGeneric #-}++-- | This module contains type definitions copied from Cabal-1.24.2.0+-- to avoid a dependency on Cabal. Their contents for the benchmark are read+-- from a cache file using their 'Read' instance, see "GenericsBenchCache".+--+module Cabal24 where++import Data.Version (Version)+import GHC.Generics (Generic)+import Data.Map (Map)++data Benchmark = Benchmark {+ benchmarkName :: String,+ benchmarkInterface :: BenchmarkInterface,+ benchmarkBuildInfo :: BuildInfo,+ benchmarkEnabled :: Bool+ } deriving (Generic, Eq, Ord, Read, Show)++data BenchmarkInterface =+ BenchmarkExeV10 Version FilePath+ | BenchmarkUnsupported BenchmarkType+ deriving (Generic, Eq, Ord, Read, Show)++data BenchmarkType = BenchmarkTypeExe Version+ | BenchmarkTypeUnknown String Version+ deriving (Generic, Eq, Ord, Read, Show)++data BuildInfo = BuildInfo {+ buildable :: Bool,+ buildTools :: [Dependency],+ cppOptions :: [String],+ ccOptions :: [String],+ ldOptions :: [String],+ pkgconfigDepends :: [Dependency],+ frameworks :: [String],+ extraFrameworkDirs:: [String],+ cSources :: [FilePath],+ jsSources :: [FilePath],+ hsSourceDirs :: [FilePath],+ otherModules :: [ModuleName],+ defaultLanguage :: Maybe Language,+ otherLanguages :: [Language],+ defaultExtensions :: [Extension],+ otherExtensions :: [Extension],+ oldExtensions :: [Extension],+ extraLibs :: [String],+ extraGHCiLibs :: [String],+ extraLibDirs :: [String],+ includeDirs :: [FilePath],+ includes :: [FilePath],+ installIncludes :: [FilePath],+ options :: [(CompilerFlavor,[String])],+ profOptions :: [(CompilerFlavor,[String])],+ sharedOptions :: [(CompilerFlavor,[String])],+ customFieldsBI :: [(String,String)],+ targetBuildDepends :: [Dependency],+ targetBuildRenaming :: Map PackageName ModuleRenaming+ } deriving (Generic, Eq, Ord, Read, Show)++data BuildType+ = Simple+ | Configure+ | Make+ | Custom+ | UnknownBuildType String+ deriving (Generic, Eq, Ord, Read, Show)++data CompilerFlavor = GHC | GHCJS | NHC | YHC | Hugs | HBC | Helium+ | JHC | LHC | UHC+ | HaskellSuite String+ | OtherCompiler String+ deriving (Generic, Eq, Ord, Read, Show)++data Dependency = Dependency PackageName VersionRange+ deriving (Generic, Eq, Ord, Read, Show)++data Executable = Executable {+ exeName :: String,+ modulePath :: FilePath,+ buildInfo :: BuildInfo+ }+ deriving (Generic, Eq, Ord, Read, Show)++data Extension =+ EnableExtension KnownExtension+ | DisableExtension KnownExtension+ | UnknownExtension String+ deriving (Generic, Eq, Ord, Read, Show)++newtype FlagName = FlagName String+ deriving (Generic, Eq, Ord, Read, Show)++data KnownExtension =+ OverlappingInstances+ | UndecidableInstances+ | IncoherentInstances+ | DoRec+ | RecursiveDo+ | ParallelListComp+ | MultiParamTypeClasses+ | MonomorphismRestriction+ | FunctionalDependencies+ | Rank2Types+ | RankNTypes+ | PolymorphicComponents+ | ExistentialQuantification+ | ScopedTypeVariables+ | PatternSignatures+ | ImplicitParams+ | FlexibleContexts+ | FlexibleInstances+ | EmptyDataDecls+ | CPP+ | KindSignatures+ | BangPatterns+ | TypeSynonymInstances+ | TemplateHaskell+ | ForeignFunctionInterface+ | Arrows+ | Generics+ | ImplicitPrelude+ | NamedFieldPuns+ | PatternGuards+ | GeneralizedNewtypeDeriving+ | ExtensibleRecords+ | RestrictedTypeSynonyms+ | HereDocuments+ | MagicHash+ | TypeFamilies+ | StandaloneDeriving+ | UnicodeSyntax+ | UnliftedFFITypes+ | InterruptibleFFI+ | CApiFFI+ | LiberalTypeSynonyms+ | TypeOperators+ | RecordWildCards+ | RecordPuns+ | DisambiguateRecordFields+ | TraditionalRecordSyntax+ | OverloadedStrings+ | GADTs+ | GADTSyntax+ | MonoPatBinds+ | RelaxedPolyRec+ | ExtendedDefaultRules+ | UnboxedTuples+ | DeriveDataTypeable+ | DeriveGeneric+ | DefaultSignatures+ | InstanceSigs+ | ConstrainedClassMethods+ | PackageImports+ | ImpredicativeTypes+ | NewQualifiedOperators+ | PostfixOperators+ | QuasiQuotes+ | TransformListComp+ | MonadComprehensions+ | ViewPatterns+ | XmlSyntax+ | RegularPatterns+ | TupleSections+ | GHCForeignImportPrim+ | NPlusKPatterns+ | DoAndIfThenElse+ | MultiWayIf+ | LambdaCase+ | RebindableSyntax+ | ExplicitForAll+ | DatatypeContexts+ | MonoLocalBinds+ | DeriveFunctor+ | DeriveTraversable+ | DeriveFoldable+ | NondecreasingIndentation+ | SafeImports+ | Safe+ | Trustworthy+ | Unsafe+ | ConstraintKinds+ | PolyKinds+ | DataKinds+ | ParallelArrays+ | RoleAnnotations+ | OverloadedLists+ | EmptyCase+ | AutoDeriveTypeable+ | NegativeLiterals+ | BinaryLiterals+ | NumDecimals+ | NullaryTypeClasses+ | ExplicitNamespaces+ | AllowAmbiguousTypes+ | JavaScriptFFI+ | PatternSynonyms+ | PartialTypeSignatures+ | NamedWildCards+ | DeriveAnyClass+ | DeriveLift+ | StaticPointers+ | StrictData+ | Strict+ | ApplicativeDo+ | DuplicateRecordFields+ | TypeApplications+ | TypeInType+ | UndecidableSuperClasses+ | MonadFailDesugaring+ | TemplateHaskellQuotes+ | OverloadedLabels+ deriving (Generic, Eq, Ord, Read, Show)++data Language =+ Haskell98+ | Haskell2010+ | UnknownLanguage String+ deriving (Generic, Eq, Ord, Read, Show)++data Library = Library {+ exposedModules :: [ModuleName],+ reexportedModules :: [ModuleReexport],+ requiredSignatures:: [ModuleName],+ exposedSignatures:: [ModuleName],+ libExposed :: Bool,+ libBuildInfo :: BuildInfo+ }+ deriving (Generic, Eq, Ord, Read, Show)++data License =+ GPL (Maybe Version)+ | AGPL (Maybe Version)+ | LGPL (Maybe Version)+ | BSD2+ | BSD3+ | BSD4+ | MIT+ | ISC+ | MPL Version+ | Apache (Maybe Version)+ | PublicDomain+ | AllRightsReserved+ | UnspecifiedLicense+ | OtherLicense+ | UnknownLicense String+ deriving (Generic, Eq, Ord, Read, Show)++newtype ModuleName = ModuleName [String]+ deriving (Generic, Eq, Ord, Read, Show)++data ModuleReexport = ModuleReexport {+ moduleReexportOriginalPackage :: Maybe PackageName,+ moduleReexportOriginalName :: ModuleName,+ moduleReexportName :: ModuleName+ } deriving (Generic, Eq, Ord, Read, Show)++data ModuleRenaming = ModuleRenaming Bool [(ModuleName, ModuleName)]+ deriving (Generic, Eq, Ord, Read, Show)++data PackageDescription+ = PackageDescription {+ package :: PackageIdentifier,+ license :: License,+ licenseFiles :: [FilePath],+ copyright :: String,+ maintainer :: String,+ author :: String,+ stability :: String,+ testedWith :: [(CompilerFlavor,VersionRange)],+ homepage :: String,+ pkgUrl :: String,+ bugReports :: String,+ sourceRepos :: [SourceRepo],+ synopsis :: String,+ description :: String,+ category :: String,+ customFieldsPD :: [(String,String)],+ buildDepends :: [Dependency],+ specVersionRaw :: Either Version VersionRange,+ buildType :: Maybe BuildType,+ setupBuildInfo :: Maybe SetupBuildInfo,+ library :: Maybe Library,+ executables :: [Executable],+ testSuites :: [TestSuite],+ benchmarks :: [Benchmark],+ dataFiles :: [FilePath],+ dataDir :: FilePath,+ extraSrcFiles :: [FilePath],+ extraTmpFiles :: [FilePath],+ extraDocFiles :: [FilePath]+ } deriving (Generic, Eq, Ord, Read, Show)++data PackageIdentifier+ = PackageIdentifier {+ pkgName :: PackageName,+ pkgVersion :: Version+ }+ deriving (Generic, Eq, Ord, Read, Show)++newtype PackageName = PackageName { unPackageName :: String }+ deriving (Generic, Eq, Ord, Read, Show)++data RepoKind =+ RepoHead+ | RepoThis+ | RepoKindUnknown String+ deriving (Generic, Eq, Ord, Read, Show)++data RepoType = Darcs | Git | SVN | CVS+ | Mercurial | GnuArch | Bazaar | Monotone+ | OtherRepoType String+ deriving (Generic, Eq, Ord, Read, Show)++data SetupBuildInfo = SetupBuildInfo {+ setupDepends :: [Dependency],+ defaultSetupDepends :: Bool+ }+ deriving (Generic, Eq, Ord, Read, Show)++data SourceRepo = SourceRepo {+ repoKind :: RepoKind,+ repoType :: Maybe RepoType,+ repoLocation :: Maybe String,+ repoModule :: Maybe String,+ repoBranch :: Maybe String,+ repoTag :: Maybe String,+ repoSubdir :: Maybe FilePath+}+ deriving (Generic, Eq, Ord, Read, Show)++data TestSuite = TestSuite {+ testName :: String,+ testInterface :: TestSuiteInterface,+ testBuildInfo :: BuildInfo,+ testEnabled :: Bool+ }+ deriving (Generic, Eq, Ord, Read, Show)++data TestSuiteInterface =+ TestSuiteExeV10 Version FilePath+ | TestSuiteLibV09 Version ModuleName+ | TestSuiteUnsupported TestType+ deriving (Generic, Eq, Ord, Read, Show)++data TestType = TestTypeExe Version+ | TestTypeLib Version+ | TestTypeUnknown String Version+ deriving (Generic, Eq, Ord, Read, Show)++data VersionRange+ = AnyVersion+ | ThisVersion Version+ | LaterVersion Version+ | EarlierVersion Version+ | WildcardVersion Version+ | UnionVersionRanges VersionRange VersionRange+ | IntersectVersionRanges VersionRange VersionRange+ | VersionRangeParens VersionRange+ deriving (Generic, Eq, Ord, Read, Show)
benchmarks/GenericsBench.hs view
@@ -2,7 +2,7 @@ module Main where import qualified Data.ByteString.Lazy as L-import Distribution.PackageDescription+import Cabal24 (PackageDescription) import Criterion.Main
benchmarks/GenericsBenchCache.hs view
@@ -1,20 +1,12 @@ {-# LANGUAGE DeriveGeneric, StandaloneDeriving, BangPatterns, CPP #-} module GenericsBenchCache (readPackageDescriptionCache) where -import qualified Text.ParserCombinators.ReadP as Read- import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy.Char8 as LC8+import qualified Codec.Compression.GZip as GZip -import Data.Version (parseVersion)-import Distribution.PackageDescription-import Distribution.PackageDescription.Configuration-import Distribution.PackageDescription.Parse-import Distribution.Version (Version)+import Cabal24 (PackageDescription) -import qualified Codec.Archive.Tar as Tar-import qualified Codec.Compression.GZip as GZip-import qualified Data.HashMap.Lazy as Map import System.Directory import System.Exit @@ -24,66 +16,25 @@ import Control.Applicative ((<$>)) #endif -readTar :: String -> Int -> IO [PackageDescription]-readTar tarPath limit = do- entries <- Tar.read . GZip.decompress <$> L.readFile tarPath- let contents = Tar.foldEntries unpack [] (error "tar error") entries- let !pkgs = Map.fromListWith pick- [ (pkg, (version, content))- | (path, content) <- contents- , Just (pkg, version) <- return (readFilePath path) ]-- return $ take limit [ flattenPackageDescription gpd- | (_, (_, content)) <- Map.toList pkgs- , ParseOk _warns gpd <- return (parsePackageDescription (LC8.unpack content)) ]- where- pick (v,a) (w,b) | v >= w = (v,a)- | otherwise = (w,b)- unpack e acc =- case Tar.entryContent e of- Tar.NormalFile content _ -> (Tar.entryPath e, content):acc- _ -> acc--readFilePath :: String -> Maybe (String, Version)-readFilePath str = extract (Read.readP_to_S parse str)- where- extract [(result,_)] = Just result- extract _ = Nothing- parse = do- packageName <- Read.many1 (Read.satisfy (/='/'))- _ <- Read.char '/'- version <- parseVersion- _ <- Read.char '/'- return (packageName, version)--writePackageDescriptionCache :: String -> [PackageDescription] -> IO ()-writePackageDescriptionCache path = writeFile path . show- readPackageDescriptionCache :: Int -> IO [PackageDescription] readPackageDescriptionCache amount = do- let cacheFilePath' = cacheFilePath ++ "-" ++ (show amount)- createPackageDescriptionCache cacheFilePath' amount- pds <- read <$> readFile cacheFilePath'+ cacheExists <- doesFileExist cacheFilePath+ bs <-+ if cacheExists+ then do+ putStrLn "reading the cache file, might take a moment..."+ L.readFile cacheFilePath+ else do+ -- In older versions of this benchmark, there was machinery to+ -- regenerate the cache using the data in @~/.cabal@. Now the cache is+ -- simply stored in the repo to avoid a dependency on Cabal the library.+ putStrLn (cacheFilePath ++ " missing, aborting")+ exitFailure+ let str = LC8.unpack (GZip.decompress bs)+ pds = take amount (read str) -- PackageDescription doesn't implement NFData, let's force with the following line- (length (show pds)) `seq` return pds+ (length (show pds)) `seq` putStrLn "done reading the cache file"+ return pds cacheFilePath :: String-cacheFilePath = "generics-bench.cache"--createPackageDescriptionCache :: String -> Int -> IO ()-createPackageDescriptionCache path amount = do- cacheExists <- doesFileExist path- if cacheExists- then putStrLn "reusing cache from previous run"- else do- putStr "creating cabal cache file... "- tarFilePath <- (++"/.cabal/packages/hackage.haskell.org/00-index.tar.gz") <$> getHomeDirectory- fileExists <- doesFileExist tarFilePath- if fileExists- then do- pds <- readTar tarFilePath amount- writePackageDescriptionCache path pds- putStrLn "done"- else do- putStrLn (tarFilePath ++ " missing, aborting")- exitFailure+cacheFilePath = "generics-bench.cache.gz"
benchmarks/GenericsBenchTypes.hs view
@@ -1,22 +1,9 @@-{-# LANGUAGE CPP, DeriveGeneric, StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module GenericsBenchTypes where -import Distribution.Compiler-import Distribution.License-import Distribution.ModuleName hiding (main)-import Distribution.Package-import Distribution.PackageDescription-import Distribution.Version-import Language.Haskell.Extension--import GHC.Generics (Generic)--import Data.Binary--#if ! MIN_VERSION_base(4,9,0)-deriving instance Generic Version-#endif+import Cabal24+import Generics.Deriving.Instances ()+import Data.Binary instance Binary Benchmark instance Binary BenchmarkInterface
binary.cabal view
@@ -1,5 +1,5 @@ name: binary-version: 0.8.5.1+version: 0.8.6.0 license: BSD3 license-file: LICENSE author: Lennart Kolmodin <kolmodin@gmail.com>@@ -64,13 +64,23 @@ other-modules: Action Arbitrary+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4, random>=1.0.1.0, test-framework, test-framework-quickcheck2 >= 0.3,- QuickCheck == 2.9.*+ QuickCheck >= 2.9 -- build dependencies from using binary source rather than depending on the library build-depends: array, containers@@ -84,6 +94,16 @@ type: exitcode-stdio-1.0 hs-source-dirs: src tests main-is: File.hs+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4,@@ -104,7 +124,17 @@ type: exitcode-stdio-1.0 hs-source-dirs: src benchmarks main-is: Benchmark.hs- other-modules: MemBench+ other-modules:+ MemBench+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4@@ -122,6 +152,16 @@ type: exitcode-stdio-1.0 hs-source-dirs: src benchmarks main-is: Get.hs+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: attoparsec, base >= 4.5.0.0 && < 5,@@ -142,6 +182,16 @@ type: exitcode-stdio-1.0 hs-source-dirs: src benchmarks main-is: Put.hs+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4,@@ -150,7 +200,6 @@ -- build dependencies from using binary source rather than depending on the library build-depends: array, containers ghc-options: -O2 -Wall- other-modules: Data.Binary.Generic if impl(ghc <= 7.6) -- prior to ghc-7.4 generics lived in ghc-prim build-depends: ghc-prim@@ -159,21 +208,33 @@ type: exitcode-stdio-1.0 hs-source-dirs: src benchmarks main-is: GenericsBench.hs+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4,- Cabal == 1.24.*,+ -- The benchmark already depended on 'generic-deriving' transitively. That's+ -- what caused one of the problems, as both 'generic-deriving' and+ -- 'GenericsBenchTypes' used to define 'instance Generic Version'.+ generic-deriving >= 0.10, directory, filepath,- tar, unordered-containers, zlib, criterion other-modules:+ Cabal24 GenericsBenchCache GenericsBenchTypes- Data.Binary.Generic -- build dependencies from using binary source rather than depending on the library build-depends: array, containers ghc-options: -O2 -Wall@@ -185,6 +246,16 @@ type: exitcode-stdio-1.0 hs-source-dirs: src benchmarks main-is: Builder.hs+ other-modules:+ Data.Binary+ Data.Binary.Builder+ Data.Binary.Class+ Data.Binary.FloatCast+ Data.Binary.Generic+ Data.Binary.Get+ Data.Binary.Get.Internal+ Data.Binary.Internal+ Data.Binary.Put build-depends: base >= 4.5.0.0 && < 5, bytestring >= 0.10.4,
changelog.md view
@@ -1,6 +1,12 @@ binary ====== +binary-0.10.0.0+---------------++- Add binary instance for Data.Functor.Identity from base, #146.+- Don't use * when we have TypeOperators, #148.+ binary-0.9.0.0 --------------
src/Data/Binary/Class.hs view
@@ -60,6 +60,9 @@ #endif import qualified Data.Monoid as Monoid import Data.Monoid ((<>))+#if MIN_VERSION_base(4,8,0)+import Data.Functor.Identity (Identity (..))+#endif #if MIN_VERSION_base(4,9,0) import qualified Data.List.NonEmpty as NE import qualified Data.Semigroup as Semigroup@@ -565,6 +568,12 @@ ------------------------------------------------------------------------ -- Container types++#if MIN_VERSION_base(4,8,0)+instance Binary a => Binary (Identity a) where+ put (Identity x) = put x+ get = Identity <$> get+#endif instance Binary a => Binary [a] where put = putList
src/Data/Binary/Generic.hs view
@@ -3,6 +3,10 @@ {-# LANGUAGE Safe #-} {-# OPTIONS_GHC -fno-warn-orphans #-} +#if __GLASGOW_HASKELL__ >= 800+#define HAS_DATA_KIND+#endif+ ----------------------------------------------------------------------------- -- | -- Module : Data.Binary.Generic@@ -27,6 +31,9 @@ import Data.Bits import Data.Word import Data.Monoid ((<>))+#ifdef HAS_DATA_KIND+import Data.Kind+#endif import GHC.Generics import Prelude -- Silence AMP warning. @@ -136,7 +143,11 @@ class SumSize f where sumSize :: Tagged f Word64 -newtype Tagged (s :: * -> *) b = Tagged {unTagged :: b}+#ifdef HAS_DATA_KIND+newtype Tagged (s :: Type -> Type) b = Tagged {unTagged :: b}+#else+newtype Tagged (s :: * -> *) b = Tagged {unTagged :: b}+#endif instance (SumSize a, SumSize b) => SumSize (a :+: b) where sumSize = Tagged $ unTagged (sumSize :: Tagged a Word64) +
tests/QC.hs view
@@ -34,7 +34,7 @@ import Test.Framework import Test.Framework.Providers.QuickCheck2-import Test.QuickCheck+import Test.QuickCheck hiding (total) import qualified Action (tests) import Arbitrary ()