Skip to content

Allow base-4.18, require binary-orphans >=1.0.3 #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.15.20220620
# version: 0.15.20220808
#
# REGENDATA ("0.15.20220620",["github","cabal.project"])
# REGENDATA ("0.15.20220808",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -32,9 +32,14 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.2.3
- compiler: ghc-9.4.1
compilerKind: ghc
compilerVersion: 9.2.3
compilerVersion: 9.4.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.4
compilerKind: ghc
compilerVersion: 9.2.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand Down Expand Up @@ -95,7 +100,7 @@ jobs:
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.17.8/x86_64-linux-ghcup-0.1.17.8 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.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.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
Expand All @@ -104,7 +109,7 @@ jobs:
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.17.8/x86_64-linux-ghcup-0.1.17.8 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.3

- Add instance for `primitive`s `ByteArray`.

## 1.0.2

- Support `aeson-2.0.0.0`
Expand Down
15 changes: 9 additions & 6 deletions binary-instances.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: binary-instances
version: 1.0.2
x-revision: 4
version: 1.0.3
synopsis: Orphan instances for binary
description:
`binary-instances` defines orphan instances for types in some popular packages.
Expand All @@ -25,7 +24,8 @@ tested-with:
|| ==8.8.4
|| ==8.10.7
|| ==9.0.2
|| ==9.2.3
|| ==9.2.4
|| ==9.4.1

extra-source-files: CHANGELOG.md

Expand All @@ -38,11 +38,12 @@ library
hs-source-dirs: src
build-depends:
aeson >=0.7.0.6 && <1.6 || >=2.0.0.0 && <2.2
, base >=4.6.0.1 && <4.17
, base >=4.6.0.1 && <4.18
, binary >=0.5.1.1 && <0.8.10
, binary-orphans >=1.0.1 && <1.1
, binary-orphans >=1.0.3 && <1.1
, case-insensitive >=1.2.0.4 && <1.2.2
, hashable >=1.2.3.3 && <1.5
, primitive >=0.7.2.0 && <0.8
, scientific >=0.3.3.8 && <0.4
, tagged >=0.7.3 && <0.8.7
, text >=1.2.0.6 && <1.3 || >=2.0 && <2.1
Expand All @@ -57,6 +58,7 @@ library
Data.Binary.Instances.Aeson
Data.Binary.Instances.CaseInsensitive
Data.Binary.Instances.Hashable
Data.Binary.Instances.Primitive
Data.Binary.Instances.Scientific
Data.Binary.Instances.Tagged
Data.Binary.Instances.Text
Expand All @@ -78,8 +80,9 @@ test-suite binary-instances-test
, bytestring
, case-insensitive
, hashable
, primitive
, QuickCheck >=2.13.1 && <2.15
, quickcheck-instances >=0.3.25 && <0.4
, quickcheck-instances >=0.3.28 && <0.4
, scientific
, tagged
, tasty >=0.10.1.2 && <1.5
Expand Down
1 change: 1 addition & 0 deletions src/Data/Binary/Instances.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Data.Binary.Orphans ()
import Data.Binary.Instances.Aeson ()
import Data.Binary.Instances.CaseInsensitive ()
import Data.Binary.Instances.Hashable ()
import Data.Binary.Instances.Primitive ()
import Data.Binary.Instances.Scientific ()
import Data.Binary.Instances.Tagged ()
import Data.Binary.Instances.Text ()
Expand Down
27 changes: 27 additions & 0 deletions src/Data/Binary/Instances/Primitive.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.Binary.Instances.Primitive where

import Data.Binary.Orphans ()

import Control.Monad (replicateM)
import Data.Binary (Binary, Get, Put, get, put)
import Data.Word (Word8)

import qualified Data.Primitive as Prim

-- | @since 1.0.3
instance Binary Prim.ByteArray where
put ba = put maxI >> go 0
where
maxI :: Int
maxI = Prim.sizeofByteArray ba

go :: Int -> Put
go i | i < maxI = put (Prim.indexByteArray ba i :: Word8) >> go (i + 1)
| otherwise = return ()

get = do
len <- get
xs <- replicateM len get
return (Prim.byteArrayFromListN len (xs :: [Word8]))
2 changes: 2 additions & 0 deletions test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Data.Vector (Vector)

import qualified Data.Vector.Unboxed as VU

import qualified Data.Primitive as Prim
import qualified Data.Time.Calendar.Compat as Time
import qualified Data.Time.Calendar.Month.Compat as Time
import qualified Data.Time.Calendar.Quarter.Compat as Time
Expand Down Expand Up @@ -70,6 +71,7 @@ tests = testGroup "Roundtrip"
-- vector
, roundtripProperty (undefined :: Vector Char)
, roundtripProperty (undefined :: VU.Vector Char)
, roundtripProperty (undefined :: Prim.ByteArray)
]

roundtrip :: (Eq a, Show a, Binary a) => a -> a -> Property
Expand Down