Skip to content

Commit 277d03b

Browse files
Prepare 0.3.16.1 release
Reformatted. Added workflows. Updated package metadata.
1 parent 0a79b2d commit 277d03b

26 files changed

+2408
-1926
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@byteverse/l3c

.github/workflows/build.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: build
2+
on:
3+
pull_request:
4+
branches:
5+
- "*"
6+
7+
jobs:
8+
call-workflow:
9+
uses: byteverse/.github/.github/workflows/build.yaml@main
10+
secrets: inherit
11+
with:
12+
release: false

.github/workflows/release.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
7+
jobs:
8+
call-workflow:
9+
uses: byteverse/.github/.github/workflows/build.yaml@main
10+
secrets: inherit
11+
with:
12+
release: true

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode/
12
dist
23
dist-*
34
cabal-dev
@@ -11,6 +12,7 @@ cabal-dev
1112
.hsenv
1213
.cabal-sandbox/
1314
cabal.sandbox.config
15+
cabal.project.local
1416
*.prof
1517
*.aux
1618
*.hp

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Note: Prior to version 0.3.4.0, this library was named
55
`small-bytearray-builder` is now just a compatibility shim
66
to ease the migration process.
77

8-
## 0.3.16.1 -- 2024-??-??
8+
## 0.3.16.1 -- 2024-02-02
99

1010
* Remove all CPP
1111
* Drop support for GHC < 9.4
@@ -141,7 +141,7 @@ to ease the migration process.
141141
* Add `flush`, `copy`, and `insert` for better control when
142142
converting byte sequences to builders.
143143
* Add `shortByteString` to improve interoperability with the
144-
`bytestring` library.
144+
`bytestring` library.
145145

146146
## 0.2.1.0 -- 2019-09-05
147147

Setup.hs

-2
This file was deleted.

bench/Cell.hs

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
{-# language OverloadedLists #-}
2-
{-# language OverloadedStrings #-}
1+
{-# LANGUAGE OverloadedLists #-}
2+
{-# LANGUAGE OverloadedStrings #-}
33

44
module Cell
5-
( Cell(..)
5+
( Cell (..)
66
, cells
77
) where
88

9-
import Data.Word (Word32)
10-
import Data.Text.Short (ShortText)
119
import Data.Primitive (SmallArray)
10+
import Data.Text.Short (ShortText)
11+
import Data.Word (Word32)
1212

1313
-- A cell in a CSV file
1414
data Cell
@@ -18,15 +18,14 @@ data Cell
1818
-- Some sample data to encode as a CSV
1919
cells :: SmallArray (SmallArray Cell)
2020
cells =
21-
[ [ CellString "Randy", CellString "Gutiérrez", CellNumber 41, CellNumber 343 ]
22-
, [ CellString "Édith", CellString "Piaf", CellNumber 63, CellNumber 453 ]
23-
, [ CellString "Martha", CellString "Washington", CellNumber 51, CellNumber 634 ]
24-
, [ CellString "Julius", CellString "Caesar", CellNumber 1, CellNumber 6922 ]
25-
, [ CellString "Robert", CellString "Redford", CellNumber 24, CellNumber 617 ]
26-
, [ CellString "Violet", CellString "Crawley", CellNumber 71, CellNumber 150 ]
27-
, [ CellString "Lázaro", CellString "Cárdenas", CellNumber 58, CellNumber 299 ]
28-
, [ CellString "Anastasia", CellString "San Martin", CellNumber 103, CellNumber 3214 ]
29-
, [ CellString "Mad", CellString "Max", CellNumber 37, CellNumber 918 ]
30-
, [ CellString "Sidonie-Gabrielle", CellString "Collette", CellNumber 25, CellNumber 904 ]
21+
[ [CellString "Randy", CellString "Gutiérrez", CellNumber 41, CellNumber 343]
22+
, [CellString "Édith", CellString "Piaf", CellNumber 63, CellNumber 453]
23+
, [CellString "Martha", CellString "Washington", CellNumber 51, CellNumber 634]
24+
, [CellString "Julius", CellString "Caesar", CellNumber 1, CellNumber 6922]
25+
, [CellString "Robert", CellString "Redford", CellNumber 24, CellNumber 617]
26+
, [CellString "Violet", CellString "Crawley", CellNumber 71, CellNumber 150]
27+
, [CellString "Lázaro", CellString "Cárdenas", CellNumber 58, CellNumber 299]
28+
, [CellString "Anastasia", CellString "San Martin", CellNumber 103, CellNumber 3214]
29+
, [CellString "Mad", CellString "Max", CellNumber 37, CellNumber 918]
30+
, [CellString "Sidonie-Gabrielle", CellString "Collette", CellNumber 25, CellNumber 904]
3131
]
32-

bench/Main.hs

+74-58
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,96 @@
1-
{-# language LambdaCase #-}
2-
{-# language OverloadedStrings #-}
1+
{-# LANGUAGE OverloadedStrings #-}
32

43
import Data.Primitive (ByteArray)
54
import Data.Word (Word64)
6-
import Gauge (bgroup,bench,whnf)
5+
import Gauge (bench, bgroup, whnf)
76
import Gauge.Main (defaultMain)
87

98
import qualified Arithmetic.Nat as Nat
109
import qualified Data.Bytes.Builder as B
1110
import qualified Data.Bytes.Builder.Bounded as U
1211

1312
import qualified Cell
14-
import qualified SimpleCsv
1513
import qualified HexWord64
14+
import qualified SimpleCsv
1615
import qualified Word16Tree
1716

1817
main :: IO ()
19-
main = defaultMain
20-
[ bgroup "w64"
21-
[ bgroup "hex"
22-
[ bench "library" (whnf encodeHexWord64s w64s)
23-
, bench "loop" (whnf encodeHexWord64sLoop w64s)
24-
]
18+
main =
19+
defaultMain
20+
[ bgroup
21+
"w64"
22+
[ bgroup
23+
"hex"
24+
[ bench "library" (whnf encodeHexWord64s w64s)
25+
, bench "loop" (whnf encodeHexWord64sLoop w64s)
26+
]
27+
]
28+
, bgroup
29+
"unbounded"
30+
[ bench "csv-no-escape" $
31+
whnf
32+
(\x -> B.run 4080 (SimpleCsv.encodeRows x))
33+
Cell.cells
34+
, bench "word-16-tree-small" $
35+
whnf
36+
(\x -> B.run 4080 (Word16Tree.encode x))
37+
Word16Tree.exampleSmall
38+
, bench "word-16-tree-2000" $
39+
whnf
40+
(\x -> B.run ((4096 * 16) - 16) (Word16Tree.encode x))
41+
Word16Tree.example2000
42+
, bench "word-16-tree-9000" $
43+
whnf
44+
(\x -> B.run ((4096 * 64) - 16) (Word16Tree.encode x))
45+
Word16Tree.example9000
46+
]
2547
]
26-
, bgroup "unbounded"
27-
[ bench "csv-no-escape" $ whnf
28-
(\x -> B.run 4080 (SimpleCsv.encodeRows x))
29-
Cell.cells
30-
, bench "word-16-tree-small" $ whnf
31-
(\x -> B.run 4080 (Word16Tree.encode x))
32-
Word16Tree.exampleSmall
33-
, bench "word-16-tree-2000" $ whnf
34-
(\x -> B.run ((4096 * 16) - 16) (Word16Tree.encode x))
35-
Word16Tree.example2000
36-
, bench "word-16-tree-9000" $ whnf
37-
(\x -> B.run ((4096 * 64) - 16) (Word16Tree.encode x))
38-
Word16Tree.example9000
39-
]
40-
]
4148

4249
w64s :: Word64s
43-
w64s = Word64s
44-
0xde2b8a480cf77113
45-
0x48f1668ca2a68b45
46-
0xd262fbaa0b2f473c
47-
0xbab20547f4919d9f
48-
0xb7ec16121704db43
49-
0x9c259f5bfa90e1eb
50-
0xd451eca11d9873ad
51-
0xbd927e8d4c879d02
50+
w64s =
51+
Word64s
52+
0xde2b8a480cf77113
53+
0x48f1668ca2a68b45
54+
0xd262fbaa0b2f473c
55+
0xbab20547f4919d9f
56+
0xb7ec16121704db43
57+
0x9c259f5bfa90e1eb
58+
0xd451eca11d9873ad
59+
0xbd927e8d4c879d02
5260

53-
data Word64s = Word64s
54-
!Word64 !Word64 !Word64 !Word64
55-
!Word64 !Word64 !Word64 !Word64
61+
data Word64s
62+
= Word64s
63+
!Word64
64+
!Word64
65+
!Word64
66+
!Word64
67+
!Word64
68+
!Word64
69+
!Word64
70+
!Word64
5671

5772
encodeHexWord64s :: Word64s -> ByteArray
58-
{-# noinline encodeHexWord64s #-}
59-
encodeHexWord64s (Word64s a b c d e f g h) = U.run Nat.constant $
60-
U.word64PaddedUpperHex a `U.append`
61-
U.word64PaddedUpperHex b `U.append`
62-
U.word64PaddedUpperHex c `U.append`
63-
U.word64PaddedUpperHex d `U.append`
64-
U.word64PaddedUpperHex e `U.append`
65-
U.word64PaddedUpperHex f `U.append`
66-
U.word64PaddedUpperHex g `U.append`
67-
U.word64PaddedUpperHex h
73+
{-# NOINLINE encodeHexWord64s #-}
74+
encodeHexWord64s (Word64s a b c d e f g h) =
75+
U.run Nat.constant $
76+
U.word64PaddedUpperHex a
77+
`U.append` U.word64PaddedUpperHex b
78+
`U.append` U.word64PaddedUpperHex c
79+
`U.append` U.word64PaddedUpperHex d
80+
`U.append` U.word64PaddedUpperHex e
81+
`U.append` U.word64PaddedUpperHex f
82+
`U.append` U.word64PaddedUpperHex g
83+
`U.append` U.word64PaddedUpperHex h
6884

6985
encodeHexWord64sLoop :: Word64s -> ByteArray
70-
{-# noinline encodeHexWord64sLoop #-}
71-
encodeHexWord64sLoop (Word64s a b c d e f g h) = U.run Nat.constant $
72-
HexWord64.word64PaddedUpperHex a `U.append`
73-
HexWord64.word64PaddedUpperHex b `U.append`
74-
HexWord64.word64PaddedUpperHex c `U.append`
75-
HexWord64.word64PaddedUpperHex d `U.append`
76-
HexWord64.word64PaddedUpperHex e `U.append`
77-
HexWord64.word64PaddedUpperHex f `U.append`
78-
HexWord64.word64PaddedUpperHex g `U.append`
79-
HexWord64.word64PaddedUpperHex h
80-
86+
{-# NOINLINE encodeHexWord64sLoop #-}
87+
encodeHexWord64sLoop (Word64s a b c d e f g h) =
88+
U.run Nat.constant $
89+
HexWord64.word64PaddedUpperHex a
90+
`U.append` HexWord64.word64PaddedUpperHex b
91+
`U.append` HexWord64.word64PaddedUpperHex c
92+
`U.append` HexWord64.word64PaddedUpperHex d
93+
`U.append` HexWord64.word64PaddedUpperHex e
94+
`U.append` HexWord64.word64PaddedUpperHex f
95+
`U.append` HexWord64.word64PaddedUpperHex g
96+
`U.append` HexWord64.word64PaddedUpperHex h

bench/SimpleCsv.hs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# language LambdaCase #-}
1+
{-# LANGUAGE LambdaCase #-}
22

33
-- A variant of CSV encoding that does not perform
44
-- any escaping or quoting. This is in its own module
@@ -8,22 +8,24 @@ module SimpleCsv
88
( encodeRows
99
) where
1010

11-
import Cell (Cell(..))
11+
import Cell (Cell (..))
1212
import Data.Primitive (SmallArray)
1313

14-
import qualified Data.Foldable as F
1514
import qualified Data.Bytes.Builder as B
15+
import qualified Data.Foldable as F
1616

1717
encodeRows :: SmallArray (SmallArray Cell) -> B.Builder
18-
encodeRows = F.foldr
19-
(\r x -> encodeSimpleCsvRow r (B.ascii '\n' <> x))
20-
mempty
18+
encodeRows =
19+
F.foldr
20+
(\r x -> encodeSimpleCsvRow r (B.ascii '\n' <> x))
21+
mempty
2122

2223
encodeSimpleCsvRow :: SmallArray Cell -> B.Builder -> B.Builder
23-
encodeSimpleCsvRow cs b = F.foldr
24-
(\c x -> encodeSimpleCsvCell c <> B.ascii ',' <> x)
25-
b
26-
cs
24+
encodeSimpleCsvRow cs b =
25+
F.foldr
26+
(\c x -> encodeSimpleCsvCell c <> B.ascii ',' <> x)
27+
b
28+
cs
2729

2830
encodeSimpleCsvCell :: Cell -> B.Builder
2931
encodeSimpleCsvCell = \case

0 commit comments

Comments
 (0)