Skip to content

Commit 883b408

Browse files
author
Anton Gushcha
authored
Merge pull request #22 from quetz/master
build with ghc-8.6.3 + tests fix
2 parents 3246c20 + f2ea8b7 commit 883b408

File tree

11 files changed

+77
-30
lines changed

11 files changed

+77
-30
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use new container infrastructure to enable caching
2-
dist: trusty
2+
dist: xenial
33
sudo: false
44

55
# Do not choose a language; we provide our own build tools.
@@ -8,8 +8,9 @@ language: generic
88
os:
99
- linux
1010
env:
11-
- STACK_YAML=stack-ghc7.10.3.yaml
12-
- STACK_YAML=stack-ghc8.0.2.yaml
11+
- STACK_YAML=stack-ghc8.2.2.yaml
12+
- STACK_YAML=stack-ghc8.4.4.yaml
13+
- STACK_YAML=stack-ghc8.6.3.yaml
1314

1415
services:
1516
- postgresql
@@ -24,7 +25,7 @@ addons:
2425
apt:
2526
packages:
2627
- libgmp-dev
27-
postgresql: "9.6"
28+
postgresql: "10"
2829

2930
before_install:
3031
# Download and unpack the stack executable

src/Database/PostgreSQL/Protocol/Codecs/Encoders.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ bytea = putByteString
4646

4747
{-# INLINE char #-}
4848
char :: Char -> Encode
49-
char = putWord8 . fromIntegral . ord
49+
char c
50+
| ord(c) >= 128 = error "Character code must be below 128"
51+
| otherwise = (putWord8 . fromIntegral . ord) c
5052

5153
{-# INLINE date #-}
5254
date :: Day -> Encode

src/Database/PostgreSQL/Protocol/Store/Encode.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
module Database.PostgreSQL.Protocol.Store.Encode
23
( Encode
34
, getEncodeLen
@@ -26,14 +27,21 @@ import Data.ByteString.Internal (toForeignPtr)
2627
import Data.Store.Core (Poke(..), unsafeEncodeWith, pokeStatePtr,
2728
pokeFromForeignPtr)
2829

30+
import qualified Data.Semigroup as Sem
31+
2932
data Encode = Encode {-# UNPACK #-} !Int !(Poke ())
3033

34+
instance Sem.Semigroup Encode where
35+
{-# INLINE (<>) #-}
36+
(Encode len1 f1) <> (Encode len2 f2) = Encode (len1 + len2) (f1 *> f2)
37+
3138
instance Monoid Encode where
3239
{-# INLINE mempty #-}
3340
mempty = Encode 0 . Poke $ \_ offset -> pure (offset, ())
41+
#if !(MIN_VERSION_base(4,11,0))
42+
mappend = (Sem.<>)
43+
#endif
3444

35-
{-# INLINE mappend #-}
36-
(Encode len1 f1) `mappend` (Encode len2 f2) = Encode (len1 + len2) (f1 *> f2)
3745

3846
instance Show Encode where
3947
show (Encode len _) = "Encode instance of length " ++ show len

stack-ghc7.10.3.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

stack-ghc8.2.2.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
resolver: lts-11.22
4+
5+
packages:
6+
- '.'
7+
# Dependency packages to be pulled from upstream that are not in the resolver
8+
# (e.g., acme-missiles-0.3)
9+
extra-deps:
10+
- socket-0.8.2.0
11+
- socket-unix-0.2.0.0
12+
# <<<<<<< HEAD
13+
# =======
14+
# - store-core-0.3
15+
# - QuickCheck-2.9.2
16+
# >>>>>>> QuickCheck tests for existing codecs
17+
18+
# Override default flag values for local packages and extra-deps
19+
flags: {}
20+
21+
# Extra package databases containing global packages
22+
extra-package-dbs: []

stack-ghc8.4.4.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
resolver: lts-12.26
4+
5+
packages:
6+
- '.'
7+
# Dependency packages to be pulled from upstream that are not in the resolver
8+
# (e.g., acme-missiles-0.3)
9+
extra-deps:
10+
- socket-0.8.2.0
11+
- socket-unix-0.2.0.0
12+
# <<<<<<< HEAD
13+
# =======
14+
# - store-core-0.3
15+
# - QuickCheck-2.9.2
16+
# >>>>>>> QuickCheck tests for existing codecs
17+
18+
# Override default flag values for local packages and extra-deps
19+
flags: {}
20+
21+
# Extra package databases containing global packages
22+
extra-package-dbs: []

stack-ghc8.0.2.yaml renamed to stack-ghc8.6.3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This file was automatically generated by 'stack init'
22
#
3-
resolver: lts-8.21
3+
resolver: lts-13.4
44

55
packages:
66
- '.'
77
# Dependency packages to be pulled from upstream that are not in the resolver
88
# (e.g., acme-missiles-0.3)
99
extra-deps:
10-
- socket-0.8.0.0
10+
- socket-0.8.2.0
1111
- socket-unix-0.2.0.0
1212
# <<<<<<< HEAD
1313
# =======

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
stack-ghc8.0.2.yaml
1+
stack-ghc8.6.3.yaml

tests/Codecs/QuickCheck.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,18 @@ testCodecsEncodeDecode :: TestTree
9595
testCodecsEncodeDecode = testGroup "Codecs property 'encode . decode = id'"
9696
[ mkCodecTest "bool" PGT.bool PE.bool PD.bool
9797
, mkCodecTest "bytea" PGT.bytea PE.bytea PD.bytea
98-
, mkCodecTest "char" PGT.char PE.char PD.char
98+
, mkCodecTest "char" PGT.char (PE.char . unAsciiChar)
99+
(fmap AsciiChar <$> PD.char)
99100
, mkCodecTest "date" PGT.date PE.date PD.date
100101
, mkCodecTest "float4" PGT.float4 PE.float4 PD.float4
101102
, mkCodecTest "float8" PGT.float8 PE.float8 PD.float8
102103
, mkCodecTest "int2" PGT.int2 PE.int2 PD.int2
103104
, mkCodecTest "int4" PGT.int4 PE.int4 PD.int4
104105
, mkCodecTest "int8" PGT.int8 PE.int8 PD.int8
105106
, mkCodecTest "interval" PGT.interval PE.interval PD.interval
106-
, mkCodecTest "json" PGT.json (PE.bsJsonText . unJsonString )
107+
, mkCodecTest "json" PGT.json (PE.bsJsonText . unJsonString)
107108
(fmap JsonString <$> PD.bsJsonText)
108-
, mkCodecTest "jsonb" PGT.jsonb (PE.bsJsonBytes .unJsonString)
109+
, mkCodecTest "jsonb" PGT.jsonb (PE.bsJsonBytes . unJsonString)
109110
(fmap JsonString <$> PD.bsJsonBytes)
110111
, mkCodecTest "numeric" PGT.numeric PE.numeric PD.numeric
111112
, mkCodecTest "text" PGT.text PE.bsText PD.bsText
@@ -145,6 +146,12 @@ testCodecsEncodePrint = testGroup
145146
-- Orphan instances
146147
--
147148

149+
newtype AsciiChar = AsciiChar { unAsciiChar :: Char }
150+
deriving (Show, Eq)
151+
152+
instance Arbitrary AsciiChar where
153+
arbitrary = AsciiChar <$> choose ('\0', '\127')
154+
148155
-- Helper to generate valid json strings
149156
newtype JsonString = JsonString { unJsonString :: B.ByteString }
150157
deriving (Show, Eq, IsString)

tests/Driver.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Data.Foldable
55
import Control.Monad
66
import Data.Maybe
77
import Data.Int
8-
import Data.Either
8+
import Data.Either hiding (fromRight)
99
import qualified Data.ByteString as B
1010
import qualified Data.ByteString.Lazy as BL
1111
import qualified Data.ByteString.Char8 as BS

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy