Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kcsongor/binary
  • SuedeHead/binary
  • Haskell-mouse/binary
3 results
Show changes
Commits on Source (65)
# This GitHub workflow config has been generated by a script via
#
# haskell-ci '--no-benchmarks' '--no-tests' 'github' 'binary.cabal'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.18.1
#
# REGENDATA ("0.18.1",["--no-benchmarks","--no-tests","github","binary.cabal"])
#
name: Haskell-CI
on:
- push
- pull_request
jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-20.04
timeout-minutes:
60
container:
image: buildpack-deps:bionic
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- compiler: ghc-9.8.1
compilerKind: ghc
compilerVersion: 9.8.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.3
compilerKind: ghc
compilerVersion: 9.6.3
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.4
compilerKind: ghc
compilerVersion: 9.4.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.6
compilerKind: ghc
compilerVersion: 9.2.6
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
compilerKind: ghc
compilerVersion: 9.0.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.10.7
compilerKind: ghc
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.0.2
compilerKind: ghc
compilerVersion: 8.0.2
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
HCVER: ${{ matrix.compilerVersion }}
- name: Set PATH and environment variables
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--disable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
HCVER: ${{ matrix.compilerVersion }}
- name: env
run: |
env
- name: write cabal config
run: |
mkdir -p $CABAL_DIR
cat >> $CABAL_CONFIG <<EOF
remote-build-reporting: anonymous
write-ghc-environment-files: never
remote-repo-cache: $CABAL_DIR/packages
logs-dir: $CABAL_DIR/logs
world-file: $CABAL_DIR/world
extra-prog-path: $CABAL_DIR/bin
symlink-bindir: $CABAL_DIR/bin
installdir: $CABAL_DIR/bin
build-summary: $CABAL_DIR/logs/build.log
store-dir: $CABAL_DIR/store
install-dirs user
prefix: $CABAL_DIR
repository hackage.haskell.org
url: http://hackage.haskell.org/
EOF
cat >> $CABAL_CONFIG <<EOF
program-default-options
ghc-options: $GHCJOBS +RTS -M3G -RTS
EOF
cat $CABAL_CONFIG
- name: versions
run: |
$HC --version || true
$HC --print-project-git-commit-id || true
$CABAL --version || true
- name: update cabal index
run: |
$CABAL v2-update -v
- name: install cabal-plan
run: |
mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz
echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
rm -f cabal-plan.xz
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v3
with:
path: source
- name: initial cabal.project for sdist
run: |
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
cat cabal.project
- name: sdist
run: |
mkdir -p sdist
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
- name: unpack
run: |
mkdir -p unpacked
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
- name: generate cabal.project
run: |
PKGDIR_binary="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/binary-[0-9.]*')"
echo "PKGDIR_binary=${PKGDIR_binary}" >> "$GITHUB_ENV"
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_binary}" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package binary" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(binary)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: restore cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
- name: install dependencies
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
- name: build w/o tests
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: build
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: cabal check
run: |
cd ${PKGDIR_binary} || false
${CABAL} -vnormal check
- name: haddock
run: |
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
- name: unconstrained build
run: |
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v3
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
......@@ -12,6 +12,7 @@
GNUmakefile
dist-boot
dist-install
dist-newstyle
ghc.mk
.cabal-sandbox
cabal.sandbox.config
# See https://github.com/hvr/multi-ghc-travis for more information
language: c
sudo: false
matrix:
include:
- env: CABALVER=1.18 CABALUPGR=1.24.* GHCVER=7.4.2
addons: {apt: {packages: [cabal-install-1.18,ghc-7.4.2], sources: [hvr-ghc]}}
- env: CABALVER=1.18 CABALUPGR=1.24.* GHCVER=7.6.3
addons: {apt: {packages: [cabal-install-1.18,ghc-7.6.3], sources: [hvr-ghc]}}
- env: CABALVER=1.22 CABALUPGR=1.24.* GHCVER=7.8.4
addons: {apt: {packages: [cabal-install-1.22,ghc-7.8.4], sources: [hvr-ghc]}}
- env: CABALVER=1.22 CABALUPGR=1.24.* GHCVER=7.10.3
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
- env: CABALVER=1.24 GHCVER=8.0.2
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2], sources: [hvr-ghc]}}
- env: CABALVER=1.24 GHCVER=8.2.2
addons: {apt: {packages: [cabal-install-1.24,ghc-8.2.2], sources: [hvr-ghc]}}
- env: CABALVER=1.24 GHCVER=8.4.3
addons: {apt: {packages: [cabal-install-1.24,ghc-8.4.3], sources: [hvr-ghc]}}
- env: CABALVER=2.4 GHCVER=8.6.1
addons: {apt: {packages: [cabal-install-2.4,ghc-8.6.1], sources: [hvr-ghc]}}
- env: CABALVER=head GHCVER=head
addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
allow_failures:
- env: CABALVER=head GHCVER=head
before_install:
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
install:
- cabal --version
- travis_retry cabal update
# workaround for https://ghc.haskell.org/trac/ghc/ticket/9221
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- cabal sandbox init
# can't use "cabal install --only-dependencies --enable-tests --enable-benchmarks" due to dep-cycle.
# must split in two separate 'cabal install's since cabal doesn't update the cabal library before it's needed in 'cabal-version' constraints.
- cabal install "bytestring >= 0.10.4" -j
- if [ -n "$CABALUPGR" ]; then
cabal install "Cabal == $CABALUPGR" -j;
fi
- cabal install "generic-deriving >= 0.10" criterion deepseq mtl "QuickCheck >= 2.8" HUnit "test-framework-quickcheck2 >= 0.3" "random >= 1.0.1.0" attoparsec cereal tar zlib -j
script:
- cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options=-fno-spec-constr
- cabal build
- cabal test
# "cabal check" disabled due to -O2 warning
# - cabal check
- cabal sdist
# check that the generated source-distribution can be built & installed
- export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;
cd dist/;
cabal sandbox init;
if [ -f "$SRC_TGZ" ]; then
cabal install --force-reinstalls "$SRC_TGZ";
else
echo "expected '$SRC_TGZ' not found";
exit 1;
fi
notifications:
email:
- kolmodin@gmail.com
# binary package #
# binary package
[![Hackage version](https://img.shields.io/hackage/v/binary.svg?label=Hackage)](https://hackage.haskell.org/package/binary) [![Stackage version](https://www.stackage.org/package/binary/badge/lts?label=Stackage)](https://www.stackage.org/package/binary) [![Build Status](https://api.travis-ci.org/kolmodin/binary.png?branch=master)](http://travis-ci.org/kolmodin/binary)
*Efficient, pure binary serialisation using lazy ByteStrings.*
*Pure binary serialisation using lazy ByteStrings.*
The ``binary`` package provides Data.Binary, containing the Binary class,
and associated methods, for serialising values to and from lazy
ByteStrings.
A key feature of ``binary`` is that the interface is both pure, and efficient.
A key feature of ``binary`` is that the interface is both pure, and
moderately efficient.
The ``binary`` package is portable to GHC and Hugs.
## Installing binary from Hackage ##
......
......@@ -37,4 +37,4 @@ readPackageDescriptionCache amount = do
return pds
cacheFilePath :: String
cacheFilePath = "generics-bench.cache.gz"
cacheFilePath = "generics-bench.cache-100.gz"
cabal-version: 3.0
-- To run tests and binaries you'll need to rename the name of the library
-- and all the local dependencies on it. If not, cabal is unable to come up
-- with a build plan.
--
-- Try this;
-- sed -i 's/\(name:\s*binary\)/\1-cabal-is-broken/' binary.cabal
-- sed -i 's/\(binary\),/\1-cabal-is-broken,/' binary.cabal
name: binary
version: 0.8.6.0
license: BSD3
version: 0.8.9.3
license: BSD-3-Clause
license-file: LICENSE
author: Lennart Kolmodin <kolmodin@gmail.com>
maintainer: Lennart Kolmodin, Don Stewart <dons00@gmail.com>
......@@ -17,14 +27,14 @@ synopsis: Binary serialisation for Haskell values using lazy ByteStrings
category: Data, Parsing
stability: provisional
build-type: Simple
cabal-version: >= 1.8
tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
tested-with: GHC == 8.0.2, GHC ==8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.6, GHC == 9.4.4, GHC == 9.6.3, GHC == 9.8.1
extra-source-files:
README.md changelog.md docs/hcar/binary-Lb.tex tools/derive/*.hs
tools/derive/*.hs
-- from the benchmark 'bench'
extra-source-files:
benchmarks/CBenchmark.h
extra-doc-files:
README.md changelog.md docs/hcar/binary-Lb.tex
source-repository head
type: git
......@@ -50,32 +60,20 @@ library
ghc-options: -O2 -Wall -fliberate-case-threshold=1000
if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
-- Due to circular dependency, we cannot make any of the test-suites or
-- benchmark depend on the binary library. Instead, for each test-suite and
-- benchmark, we include the source directory of binary and build-depend on all
-- the dependencies binary has.
ghc-options: -Wcompat -Wnoncanonical-monad-instances
default-language: Haskell2010
test-suite qc
type: exitcode-stdio-1.0
hs-source-dirs: src tests
hs-source-dirs: tests
main-is: QC.hs
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,
base-orphans >=0.8.1 && <0.9,
binary,
bytestring >= 0.10.4,
random>=1.0.1.0,
test-framework,
......@@ -88,24 +86,16 @@ test-suite qc
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
test-suite read-write-file
type: exitcode-stdio-1.0
hs-source-dirs: src tests
hs-source-dirs: 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,
binary,
bytestring >= 0.10.4,
Cabal,
directory,
......@@ -118,25 +108,18 @@ test-suite read-write-file
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
benchmark bench
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
hs-source-dirs: benchmarks
main-is: Benchmark.hs
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,
binary,
bytestring >= 0.10.4
-- build dependencies from using binary source rather than depending on the library
build-depends: array, containers
......@@ -146,25 +129,17 @@ benchmark bench
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
benchmark get
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
hs-source-dirs: 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,
binary,
bytestring >= 0.10.4,
cereal,
criterion == 1.*,
......@@ -176,24 +151,16 @@ benchmark get
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
benchmark put
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
hs-source-dirs: 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,
binary,
bytestring >= 0.10.4,
criterion == 1.*,
deepseq
......@@ -203,23 +170,15 @@ benchmark put
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
benchmark generics-bench
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
hs-source-dirs: 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,
binary,
bytestring >= 0.10.4,
-- The benchmark already depended on 'generic-deriving' transitively. That's
-- what caused one of the problems, as both 'generic-deriving' and
......@@ -241,23 +200,15 @@ benchmark generics-bench
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
benchmark builder
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
hs-source-dirs: 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,
binary,
bytestring >= 0.10.4,
criterion == 1.*,
deepseq,
......@@ -268,3 +219,4 @@ benchmark builder
if impl(ghc <= 7.6)
-- prior to ghc-7.4 generics lived in ghc-prim
build-depends: ghc-prim
default-language: Haskell2010
binary
======
binary-0.10.0.0
---------------
binary-0.8.9.3
--------------
- Add binary instance for Data.Functor.Identity from base, #146.
- Don't use * when we have TypeOperators, #148.
- Drop `-Wnoncanonical-monadfail-instances` from build flags
binary-0.8.9.2
--------------
- Documentation improvements
- Ensure that `many` has an unfolding
- Import `Data.List` as qualified
binary-0.8.9.1
--------------
- Fix redundant pattern match warning in GHC 9.4
binary-0.8.9.0
--------------
binary-0.9.0.0
- Compatibility with GHC 9.2
- Drop instances for deprecated `Data.Semigroup.Option`
binary-0.8.8.0
--------------
- Support Int32Rep and Word32Rep (3e0134df).
- Use bases built-in float/word32 and double/word64 casts (8eae4af0).
binary-0.8.7.0
--------------
- MonadFail compatibility in base-4.13 (`fail` is not method of `Monad).
- `Binary NonEmpty` `fail`s non empty lists, not `error`s
binary-0.9.0.0 & binary-0.10.0.0
--------------------------------
- `0.8.5.0` was first released as version `0.9.0.0`. It didn't have any
breaking changes though, so it was again released as version `0.8.5.0`
according to PVP. Next breaking release of `binary` will be version
`0.10.0.0`.
according to PVP.
- `0.8.6.0` was first released as version `0.10.0.0`.
binary-0.8.6.0
---------------
- Add binary instance for Data.Functor.Identity from base, #146.
- Don't use * when we have TypeOperators, #148.
binary-0.8.5.0
--------------
......
......@@ -22,21 +22,21 @@
version: '3'
services:
binary_ghc861:
binary_ghc865:
build:
context: .
dockerfile: docker/Dockerfile.anyghc
args:
- ghcver=8.6.1
- ghcver=8.6.5
volumes:
- cabal-store-cache:/root/.cabal/store
binary_ghc843:
binary_ghc844:
build:
context: .
dockerfile: docker/Dockerfile.anyghc
args:
- ghcver=8.4.3
- ghcver=8.4.4
volumes:
- cabal-store-cache:/root/.cabal/store
......@@ -85,15 +85,6 @@ services:
volumes:
- cabal-store-cache:/root/.cabal/store
binary_ghc742:
build:
context: .
dockerfile: docker/Dockerfile.anyghc
args:
- ghcver=7.4.2
volumes:
- cabal-store-cache:/root/.cabal/store
volumes:
cabal-store-cache:
driver: local
File added
......@@ -132,7 +132,7 @@ import System.IO ( withBinaryFile, IOMode(ReadMode) )
-- > > let e = OpE "*" (IntE 7) (OpE "/" (IntE 4) (IntE 2))
-- > > let v = encode e
--
-- Where 'v' is a binary encoded data structure. To reconstruct the
-- Where @v@ is a binary encoded data structure. To reconstruct the
-- original data, we use 'decode'
--
-- > > decode v :: Exp
......@@ -177,7 +177,7 @@ decode = runGet get
-- consumed bytes is returned. In case of failure, a human-readable error
-- message will be returned as well.
--
-- /Since: 0.7.0.0/
-- @since 0.7.0.0
decodeOrFail :: Binary a => L.ByteString
-> Either (L.ByteString, ByteOffset, String)
(L.ByteString, ByteOffset, a)
......@@ -203,7 +203,7 @@ encodeFile f v = L.writeFile f (encode v)
-- | Decode a value from a file. In case of errors, 'error' will
-- be called with the error message.
--
-- /Since: 0.7.0.0/
-- @since 0.7.0.0
decodeFile :: Binary a => FilePath -> IO a
decodeFile f = do
result <- decodeFileOrFail f
......
......@@ -9,6 +9,10 @@
{-# LANGUAGE PolyKinds #-}
#endif
#if MIN_VERSION_base(4,16,0)
#define HAS_TYPELITS_CHAR
#endif
#if MIN_VERSION_base(4,8,0)
#define HAS_NATURAL
#define HAS_VOID
......@@ -43,6 +47,9 @@ module Data.Binary.Class (
) where
import Prelude hiding (Foldable(..))
import Data.Foldable (Foldable(..))
import Data.Word
import Data.Bits
import Data.Int
......@@ -75,7 +82,7 @@ import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Builder.Prim as Prim
import Data.List (unfoldr, foldl')
import Data.List (unfoldr)
-- And needed for the instances:
#if MIN_VERSION_base(4,10,0)
......@@ -106,6 +113,10 @@ import Numeric.Natural
import qualified Data.Fixed as Fixed
#if __GLASGOW_HASKELL__ >= 901
import GHC.Exts (Levity(Lifted,Unlifted))
#endif
--
-- This isn't available in older Hugs or older GHC
--
......@@ -174,7 +185,7 @@ defaultPutList xs = put (length xs) <> mapM_ put xs
-- Void never gets written nor reconstructed since it's impossible to have a
-- value of that type
-- | /Since: 0.8.0.0/
-- | @since 0.8.0.0
instance Binary Void where
put = absurd
get = mzero
......@@ -339,7 +350,7 @@ instance Binary Integer where
let v = roll bytes
return $! if sign == (1 :: Word8) then v else - v
-- | /Since: 0.8.0.0/
-- | @since 0.8.0.0
#ifdef HAS_FIXED_CONSTRUCTOR
instance Binary (Fixed.Fixed a) where
put (Fixed.MkFixed a) = put a
......@@ -369,7 +380,7 @@ roll = foldl' unstep 0 . reverse
-- Fixed-size type for a subset of Natural
type NaturalWord = Word64
-- | /Since: 0.7.3.0/
-- | @since 0.7.3.0
instance Binary Natural where
{-# INLINE put #-}
put n | n <= hi =
......@@ -582,7 +593,7 @@ instance Binary a => Binary [a] where
get = do n <- get :: Get Int
getMany n
-- | 'getMany n' get 'n' elements in order, without blowing the stack.
-- | @'getMany' n@ get @n@ elements in order, without blowing the stack.
getMany :: Binary a => Int -> Get [a]
getMany n = go [] n
where
......@@ -675,6 +686,7 @@ instance (Binary e) => Binary (Seq.Seq e) where
------------------------------------------------------------------------
-- Floating point
-- | Uses non-IEEE754 encoding. Does not round-trip NaN.
instance Binary Double where
put d = put (decodeFloat d)
get = do
......@@ -682,6 +694,7 @@ instance Binary Double where
y <- get
return $! encodeFloat x y
-- | Uses non-IEEE754 encoding. Does not round-trip NaN.
instance Binary Float where
put f = put (decodeFloat f)
get = do
......@@ -727,7 +740,7 @@ instance (Binary i, Ix i, Binary e, IArray UArray e) => Binary (UArray i e) wher
------------------------------------------------------------------------
-- Fingerprints
-- | /Since: 0.7.6.0/
-- | @since 0.7.6.0
instance Binary Fingerprint where
put (Fingerprint x1 x2) = put x1 <> put x2
get = do
......@@ -738,7 +751,7 @@ instance Binary Fingerprint where
------------------------------------------------------------------------
-- Version
-- | /Since: 0.8.0.0/
-- | @since 0.8.0.0
instance Binary Version where
put (Version br tags) = put br <> put tags
get = Version <$> get <*> get
......@@ -746,43 +759,43 @@ instance Binary Version where
------------------------------------------------------------------------
-- Data.Monoid datatypes
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Monoid.Dual a) where
get = fmap Monoid.Dual get
put = put . Monoid.getDual
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary Monoid.All where
get = fmap Monoid.All get
put = put . Monoid.getAll
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary Monoid.Any where
get = fmap Monoid.Any get
put = put . Monoid.getAny
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Monoid.Sum a) where
get = fmap Monoid.Sum get
put = put . Monoid.getSum
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Monoid.Product a) where
get = fmap Monoid.Product get
put = put . Monoid.getProduct
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Monoid.First a) where
get = fmap Monoid.First get
put = put . Monoid.getFirst
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Monoid.Last a) where
get = fmap Monoid.Last get
put = put . Monoid.getLast
#if MIN_VERSION_base(4,8,0)
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary (f a) => Binary (Monoid.Alt f a) where
get = fmap Monoid.Alt get
put = put . Monoid.getAlt
......@@ -792,37 +805,39 @@ instance Binary (f a) => Binary (Monoid.Alt f a) where
------------------------------------------------------------------------
-- Data.Semigroup datatypes
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Semigroup.Min a) where
get = fmap Semigroup.Min get
put = put . Semigroup.getMin
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Semigroup.Max a) where
get = fmap Semigroup.Max get
put = put . Semigroup.getMax
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Semigroup.First a) where
get = fmap Semigroup.First get
put = put . Semigroup.getFirst
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (Semigroup.Last a) where
get = fmap Semigroup.Last get
put = put . Semigroup.getLast
-- | /Since: 0.8.4.0/
#if __GLASGOW_HASKELL__ < 901
-- | @since 0.8.4.0
instance Binary a => Binary (Semigroup.Option a) where
get = fmap Semigroup.Option get
put = put . Semigroup.getOption
#endif
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary m => Binary (Semigroup.WrappedMonoid m) where
get = fmap Semigroup.WrapMonoid get
put = put . Semigroup.unwrapMonoid
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance (Binary a, Binary b) => Binary (Semigroup.Arg a b) where
get = liftM2 Semigroup.Arg get get
put (Semigroup.Arg a b) = put a <> put b
......@@ -830,9 +845,13 @@ instance (Binary a, Binary b) => Binary (Semigroup.Arg a b) where
------------------------------------------------------------------------
-- Non-empty lists
-- | /Since: 0.8.4.0/
-- | @since 0.8.4.0
instance Binary a => Binary (NE.NonEmpty a) where
get = fmap NE.fromList get
get = do
list <- get
case list of
[] -> fail "NonEmpty is empty!"
x:xs -> pure (x NE.:| xs)
put = put . NE.toList
#endif
......@@ -860,23 +879,28 @@ instance Binary a => Binary (NE.NonEmpty a) where
-- * 'SomeTypeRep' (also known as 'Data.Typeable.TypeRep')
--
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary VecCount where
put = putWord8 . fromIntegral . fromEnum
get = toEnum . fromIntegral <$> getWord8
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary VecElem where
put = putWord8 . fromIntegral . fromEnum
get = toEnum . fromIntegral <$> getWord8
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary RuntimeRep where
put (VecRep a b) = putWord8 0 >> put a >> put b
put (TupleRep reps) = putWord8 1 >> put reps
put (SumRep reps) = putWord8 2 >> put reps
#if __GLASGOW_HASKELL__ >= 901
put (BoxedRep Lifted) = putWord8 3
put (BoxedRep Unlifted) = putWord8 4
#else
put LiftedRep = putWord8 3
put UnliftedRep = putWord8 4
#endif
put IntRep = putWord8 5
put WordRep = putWord8 6
put Int64Rep = putWord8 7
......@@ -889,6 +913,10 @@ instance Binary RuntimeRep where
put Word8Rep = putWord8 13
put Int16Rep = putWord8 14
put Word16Rep = putWord8 15
#if __GLASGOW_HASKELL__ >= 809
put Int32Rep = putWord8 16
put Word32Rep = putWord8 17
#endif
#endif
get = do
......@@ -897,8 +925,13 @@ instance Binary RuntimeRep where
0 -> VecRep <$> get <*> get
1 -> TupleRep <$> get
2 -> SumRep <$> get
#if __GLASGOW_HASKELL__ >= 901
3 -> pure (BoxedRep Lifted)
4 -> pure (BoxedRep Unlifted)
#else
3 -> pure LiftedRep
4 -> pure UnliftedRep
#endif
5 -> pure IntRep
6 -> pure WordRep
7 -> pure Int64Rep
......@@ -911,10 +944,14 @@ instance Binary RuntimeRep where
13 -> pure Word8Rep
14 -> pure Int16Rep
15 -> pure Word16Rep
#if __GLASGOW_HASKELL__ >= 809
16 -> pure Int32Rep
17 -> pure Word32Rep
#endif
#endif
_ -> fail "GHCi.TH.Binary.putRuntimeRep: invalid tag"
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary TyCon where
put tc = do
put (tyConPackage tc)
......@@ -924,7 +961,7 @@ instance Binary TyCon where
put (tyConKindRep tc)
get = mkTyCon <$> get <*> get <*> get <*> get <*> get
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary KindRep where
put (KindRepTyConApp tc k) = putWord8 0 >> put tc >> put k
put (KindRepVar bndr) = putWord8 1 >> put bndr
......@@ -944,21 +981,24 @@ instance Binary KindRep where
5 -> KindRepTypeLit <$> get <*> get
_ -> fail "GHCi.TH.Binary.putKindRep: invalid tag"
-- | @since 0.8.5.0. See #typeable-instances#
-- | @since 0.8.5.0
instance Binary TypeLitSort where
put TypeLitSymbol = putWord8 0
put TypeLitNat = putWord8 1
#ifdef HAS_TYPELITS_CHAR
put TypeLitChar = putWord8 2
#endif
get = do
tag <- getWord8
case tag of
0 -> pure TypeLitSymbol
1 -> pure TypeLitNat
#ifdef HAS_TYPELITS_CHAR
2 -> pure TypeLitChar
#endif
_ -> fail "GHCi.TH.Binary.putTypeLitSort: invalid tag"
putTypeRep :: TypeRep a -> Put
-- Special handling for TYPE, (->), and RuntimeRep due to recursive kind
-- relations.
-- See Note [Mutually recursive representations of primitive types]
putTypeRep rep -- Handle Type specially since it's so common
| Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type)
= put (0 :: Word8)
......@@ -970,11 +1010,17 @@ putTypeRep (App f x) = do
put (2 :: Word8)
putTypeRep f
putTypeRep x
#if __GLASGOW_HASKELL__ < 903
-- N.B. This pattern never matches,
-- even on versions of GHC older than 9.3:
-- a `Fun` typerep will match with the `App` pattern.
-- This match is kept solely for pattern-match warnings,
-- which are incorrect on GHC prior to 9.3.
putTypeRep (Fun arg res) = do
put (3 :: Word8)
putTypeRep arg
putTypeRep res
putTypeRep _ = error "GHCi.TH.Binary.putTypeRep: Impossible"
#endif
getSomeTypeRep :: Get SomeTypeRep
getSomeTypeRep = do
......@@ -1002,14 +1048,6 @@ getSomeTypeRep = do
[ "Applied type: " ++ show f
, "To argument: " ++ show x
]
3 -> do SomeTypeRep arg <- getSomeTypeRep
SomeTypeRep res <- getSomeTypeRep
case typeRepKind arg `eqTypeRep` (typeRep :: TypeRep Type) of
Just HRefl ->
case typeRepKind res `eqTypeRep` (typeRep :: TypeRep Type) of
Just HRefl -> return $ SomeTypeRep $ Fun arg res
Nothing -> failure "Kind mismatch" []
Nothing -> failure "Kind mismatch" []
_ -> failure "Invalid SomeTypeRep" []
where
failure description info =
......@@ -1033,4 +1071,3 @@ instance Binary SomeTypeRep where
put (SomeTypeRep rep) = putTypeRep rep
get = getSomeTypeRep
#endif
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
#if !(MIN_VERSION_base(4,11,0))
{-# LANGUAGE Trustworthy #-}
#endif
-- | This module was written based on
-- <http://hackage.haskell.org/package/reinterpret-cast-0.1.0/docs/src/Data-ReinterpretCast-Internal-ImplArray.html>.
......@@ -8,33 +10,52 @@
-- Implements casting via a 1-element STUArray, as described in
-- <http://stackoverflow.com/a/7002812/263061>.
module Data.Binary.FloatCast
( floatToWord
, wordToFloat
, doubleToWord
, wordToDouble
( floatToWord -- | Reinterpret-casts a `Float` to a `Word32`.
, wordToFloat -- | Reinterpret-casts a `Word32` to a `Float`.
, doubleToWord -- | Reinterpret-casts a `Double` to a `Word64`.
, wordToDouble -- | Reinterpret-casts a `Word64` to a `Double`.
) where
#if MIN_VERSION_base(4,11,0)
import Data.Word (Word32, Word64)
import GHC.Float (castWord32ToFloat, castFloatToWord32, castWord64ToDouble, castDoubleToWord64)
floatToWord :: Float -> Word32
floatToWord = castFloatToWord32
{-# INLINE floatToWord #-}
wordToFloat :: Word32 -> Float
wordToFloat = castWord32ToFloat
{-# INLINE wordToFloat #-}
doubleToWord :: Double -> Word64
doubleToWord = castDoubleToWord64
{-# INLINE doubleToWord #-}
wordToDouble :: Word64 -> Double
wordToDouble = castWord64ToDouble
{-# INLINE wordToDouble #-}
#else
import Data.Word (Word32, Word64)
import Data.Array.ST (newArray, readArray, MArray, STUArray)
import Data.Array.Unsafe (castSTUArray)
import GHC.ST (runST, ST)
-- | Reinterpret-casts a `Float` to a `Word32`.
floatToWord :: Float -> Word32
floatToWord x = runST (cast x)
{-# INLINE floatToWord #-}
-- | Reinterpret-casts a `Word32` to a `Float`.
wordToFloat :: Word32 -> Float
wordToFloat x = runST (cast x)
{-# INLINE wordToFloat #-}
-- | Reinterpret-casts a `Double` to a `Word64`.
doubleToWord :: Double -> Word64
doubleToWord x = runST (cast x)
{-# INLINE doubleToWord #-}
-- | Reinterpret-casts a `Word64` to a `Double`.
wordToDouble :: Word64 -> Double
wordToDouble x = runST (cast x)
{-# INLINE wordToDouble #-}
......@@ -43,3 +64,4 @@ cast :: (MArray (STUArray s) a (ST s),
MArray (STUArray s) b (ST s)) => a -> ST s b
cast x = newArray (0 :: Int, 0) x >>= castSTUArray >>= flip readArray 0
{-# INLINE cast #-}
#endif
......@@ -41,7 +41,7 @@
-- The fields in @Trade@ are marked as strict (using @!@) since we don't need
-- laziness here. In practise, you would probably consider using the UNPACK
-- pragma as well.
-- <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#unpack-pragma>
-- <https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/pragmas.html#unpack-pragma>
--
-- Now, let's have a look at a decoder for this format.
--
......@@ -126,7 +126,7 @@
-- from a socket which has higher likelihood to fail. To address these needs,
-- use the incremental input method like in @incrementalExample@.
-- For an example of how to read incrementally from a Handle,
-- see the implementation of 'decodeFileOrFail' in "Data.Binary".
-- see the implementation of 'Data.Binary.decodeFileOrFail'.
-----------------------------------------------------------------------------
......@@ -231,12 +231,6 @@ import qualified Data.ByteString.Lazy.Internal as L
import Data.Binary.Get.Internal hiding ( Decoder(..), runGetIncremental )
import qualified Data.Binary.Get.Internal as I
#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
-- needed for (# unboxing #) with magic hash
import GHC.Base
import GHC.Word
#endif
-- needed for casting words to float/double
import Data.Binary.FloatCast (wordToFloat, wordToDouble)
......@@ -328,7 +322,7 @@ dropHeadChunk lbs =
-- consumed is returned. In the case of failure, a human-readable
-- error message is included as well.
--
-- /Since: 0.6.4.0/
-- @since 0.6.4.0
runGetOrFail :: Get a -> L.ByteString
-> Either (L.ByteString, ByteOffset, String) (L.ByteString, ByteOffset, a)
runGetOrFail g lbs0 = feedAll (runGetIncremental g) lbs0
......@@ -366,7 +360,7 @@ pushChunk r inp =
-- | Feed a 'Decoder' with more input. If the 'Decoder' is 'Done' or 'Fail' it
-- will add the input to 'ByteString' of unconsumed input.
-- will add the input to 'L.ByteString' of unconsumed input.
--
-- @
-- 'runGetIncremental' myParser \`pushChunks\` myLazyByteString
......@@ -463,7 +457,7 @@ getWord16be = readN 2 word16be
word16be :: B.ByteString -> Word16
word16be = \s ->
(fromIntegral (s `B.unsafeIndex` 0) `shiftl_w16` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 1))
{-# INLINE[2] getWord16be #-}
{-# INLINE word16be #-}
......@@ -474,7 +468,7 @@ getWord16le = readN 2 word16le
word16le :: B.ByteString -> Word16
word16le = \s ->
(fromIntegral (s `B.unsafeIndex` 1) `shiftl_w16` 8) .|.
(fromIntegral (s `B.unsafeIndex` 1) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) )
{-# INLINE[2] getWord16le #-}
{-# INLINE word16le #-}
......@@ -485,9 +479,9 @@ getWord32be = readN 4 word32be
word32be :: B.ByteString -> Word32
word32be = \s ->
(fromIntegral (s `B.unsafeIndex` 0) `shiftl_w32` 24) .|.
(fromIntegral (s `B.unsafeIndex` 1) `shiftl_w32` 16) .|.
(fromIntegral (s `B.unsafeIndex` 2) `shiftl_w32` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) `unsafeShiftL` 24) .|.
(fromIntegral (s `B.unsafeIndex` 1) `unsafeShiftL` 16) .|.
(fromIntegral (s `B.unsafeIndex` 2) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 3) )
{-# INLINE[2] getWord32be #-}
{-# INLINE word32be #-}
......@@ -498,9 +492,9 @@ getWord32le = readN 4 word32le
word32le :: B.ByteString -> Word32
word32le = \s ->
(fromIntegral (s `B.unsafeIndex` 3) `shiftl_w32` 24) .|.
(fromIntegral (s `B.unsafeIndex` 2) `shiftl_w32` 16) .|.
(fromIntegral (s `B.unsafeIndex` 1) `shiftl_w32` 8) .|.
(fromIntegral (s `B.unsafeIndex` 3) `unsafeShiftL` 24) .|.
(fromIntegral (s `B.unsafeIndex` 2) `unsafeShiftL` 16) .|.
(fromIntegral (s `B.unsafeIndex` 1) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) )
{-# INLINE[2] getWord32le #-}
{-# INLINE word32le #-}
......@@ -511,13 +505,13 @@ getWord64be = readN 8 word64be
word64be :: B.ByteString -> Word64
word64be = \s ->
(fromIntegral (s `B.unsafeIndex` 0) `shiftl_w64` 56) .|.
(fromIntegral (s `B.unsafeIndex` 1) `shiftl_w64` 48) .|.
(fromIntegral (s `B.unsafeIndex` 2) `shiftl_w64` 40) .|.
(fromIntegral (s `B.unsafeIndex` 3) `shiftl_w64` 32) .|.
(fromIntegral (s `B.unsafeIndex` 4) `shiftl_w64` 24) .|.
(fromIntegral (s `B.unsafeIndex` 5) `shiftl_w64` 16) .|.
(fromIntegral (s `B.unsafeIndex` 6) `shiftl_w64` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) `unsafeShiftL` 56) .|.
(fromIntegral (s `B.unsafeIndex` 1) `unsafeShiftL` 48) .|.
(fromIntegral (s `B.unsafeIndex` 2) `unsafeShiftL` 40) .|.
(fromIntegral (s `B.unsafeIndex` 3) `unsafeShiftL` 32) .|.
(fromIntegral (s `B.unsafeIndex` 4) `unsafeShiftL` 24) .|.
(fromIntegral (s `B.unsafeIndex` 5) `unsafeShiftL` 16) .|.
(fromIntegral (s `B.unsafeIndex` 6) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 7) )
{-# INLINE[2] getWord64be #-}
{-# INLINE word64be #-}
......@@ -528,13 +522,13 @@ getWord64le = readN 8 word64le
word64le :: B.ByteString -> Word64
word64le = \s ->
(fromIntegral (s `B.unsafeIndex` 7) `shiftl_w64` 56) .|.
(fromIntegral (s `B.unsafeIndex` 6) `shiftl_w64` 48) .|.
(fromIntegral (s `B.unsafeIndex` 5) `shiftl_w64` 40) .|.
(fromIntegral (s `B.unsafeIndex` 4) `shiftl_w64` 32) .|.
(fromIntegral (s `B.unsafeIndex` 3) `shiftl_w64` 24) .|.
(fromIntegral (s `B.unsafeIndex` 2) `shiftl_w64` 16) .|.
(fromIntegral (s `B.unsafeIndex` 1) `shiftl_w64` 8) .|.
(fromIntegral (s `B.unsafeIndex` 7) `unsafeShiftL` 56) .|.
(fromIntegral (s `B.unsafeIndex` 6) `unsafeShiftL` 48) .|.
(fromIntegral (s `B.unsafeIndex` 5) `unsafeShiftL` 40) .|.
(fromIntegral (s `B.unsafeIndex` 4) `unsafeShiftL` 32) .|.
(fromIntegral (s `B.unsafeIndex` 3) `unsafeShiftL` 24) .|.
(fromIntegral (s `B.unsafeIndex` 2) `unsafeShiftL` 16) .|.
(fromIntegral (s `B.unsafeIndex` 1) `unsafeShiftL` 8) .|.
(fromIntegral (s `B.unsafeIndex` 0) )
{-# INLINE[2] getWord64le #-}
{-# INLINE word64le #-}
......@@ -651,27 +645,3 @@ getDoublele = wordToDouble <$> getWord64le
getDoublehost :: Get Double
getDoublehost = wordToDouble <$> getWord64host
{-# INLINE getDoublehost #-}
------------------------------------------------------------------------
-- Unchecked shifts
shiftl_w16 :: Word16 -> Int -> Word16
shiftl_w32 :: Word32 -> Int -> Word32
shiftl_w64 :: Word64 -> Int -> Word64
#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
shiftl_w16 (W16# w) (I# i) = W16# (w `uncheckedShiftL#` i)
shiftl_w32 (W32# w) (I# i) = W32# (w `uncheckedShiftL#` i)
#if WORD_SIZE_IN_BITS < 64
shiftl_w64 (W64# w) (I# i) = W64# (w `uncheckedShiftL64#` i)
#else
shiftl_w64 (W64# w) (I# i) = W64# (w `uncheckedShiftL#` i)
#endif
#else
shiftl_w16 = shiftL
shiftl_w32 = shiftL
shiftl_w64 = shiftL
#endif
......@@ -130,7 +130,7 @@ instance Applicative Get where
(<*>) = apG
{-# INLINE (<*>) #-}
-- | /Since: 0.7.1.0/
-- | @since 0.7.1.0
instance MonadPlus Get where
mzero = empty
mplus = (<|>)
......@@ -201,7 +201,7 @@ bytesRead = C $ \inp k -> BytesRead (fromIntegral $ B.length inp) (k inp)
-- Offset from 'bytesRead' will be relative to the start of 'isolate', not the
-- absolute of the input.
--
-- /Since: 0.7.2.0/
-- @since 0.7.2.0
isolate :: Int -- ^ The number of bytes that must be consumed
-> Get a -- ^ The decoder to isolate
-> Get a
......@@ -264,7 +264,7 @@ getBytes :: Int -> Get B.ByteString
getBytes = getByteString
{-# INLINE getBytes #-}
-- | /Since: 0.7.0.0/
-- | @since 0.7.0.0
instance Alternative Get where
empty = C $ \inp _ks -> Fail inp "Data.Binary.Get(Alternative).empty"
{-# INLINE empty #-}
......@@ -282,7 +282,7 @@ instance Alternative Get where
case v of
Nothing -> pure []
Just x -> (:) x <$> many p
{-# INLINE many #-}
{-# INLINEABLE many #-} -- many will never inline because it's recursive, so mark it INLINEABLE instead.
-- | Run a decoder and keep track of all the input it consumes.
-- Once it's finished, return the final decoder (always 'Done' or 'Fail'),
......@@ -312,7 +312,7 @@ pushFront bs = C $ \ inp ks -> ks (B.append bs inp) ()
-- | Run the given decoder, but without consuming its input. If the given
-- decoder fails, then so will this function.
--
-- /Since: 0.7.0.0/
-- @since 0.7.0.0
lookAhead :: Get a -> Get a
lookAhead g = do
(decoder, bs) <- runAndKeepTrack g
......@@ -325,7 +325,7 @@ lookAhead g = do
-- If 'Nothing' is returned, the input will be unconsumed.
-- If the given decoder fails, then so will this function.
--
-- /Since: 0.7.0.0/
-- @since 0.7.0.0
lookAheadM :: Get (Maybe a) -> Get (Maybe a)
lookAheadM g = do
let g' = maybe (Left ()) Right <$> g
......@@ -335,7 +335,7 @@ lookAheadM g = do
-- If 'Left' is returned, the input will be unconsumed.
-- If the given decoder fails, then so will this function.
--
-- /Since: 0.7.1.0/
-- @since 0.7.1.0
lookAheadE :: Get (Either a b) -> Get (Either a b)
lookAheadE g = do
(decoder, bs) <- runAndKeepTrack g
......@@ -348,7 +348,7 @@ lookAheadE g = do
-- | Label a decoder. If the decoder fails, the label will be appended on
-- a new line to the error message string.
--
-- /Since: 0.7.2.0/
-- @since 0.7.2.0
label :: String -> Get a -> Get a
label msg decoder = C $ \inp ks ->
let r0 = runCont decoder inp (\inp' a -> Done inp' a)
......
......@@ -24,6 +24,8 @@ import Data.Ratio
import Data.Typeable
import System.IO.Unsafe
import Data.Orphans ()
#ifdef HAS_NATURAL
import Numeric.Natural
#endif
......@@ -41,7 +43,7 @@ import Arbitrary ()
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import qualified Data.Binary.Class as Class
------------------------------------------------------------------------
......@@ -158,7 +160,7 @@ testTypeable :: Test
testTypeable = testProperty "TypeRep" prop_TypeRep
prop_TypeRep :: TypeRep -> Property
prop_TypeRep = roundTripWith Class.put Class.get
prop_TypeRep = roundTripWith put get
atomicTypeReps :: [TypeRep]
atomicTypeReps =
......@@ -499,10 +501,6 @@ genNaturalBig = do
genFingerprint :: Gen Fingerprint
genFingerprint = liftM2 Fingerprint arbitrary arbitrary
#if !MIN_VERSION_base(4,7,0)
instance Show Fingerprint where
show (Fingerprint x1 x2) = show (x1,x2)
#endif
------------------------------------------------------------------------
......