Skip to content

Commit 6cad358

Browse files
Prepare for 0.2.7.1 release.
* Added workflows. * Reformatted code. * Updated cabal file.
1 parent 135c070 commit 6cad358

File tree

18 files changed

+951
-642
lines changed

18 files changed

+951
-642
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode/
12
dist
23
dist-*
34
cabal-dev

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for json-syntax
22

3+
## 0.2.7.1 -- 2024-01-29
4+
5+
* Update package metadata.
6+
37
## 0.2.7.0 -- 2023-10-05
48

59
* Add `decodeNewlineDelimited`.
@@ -19,7 +23,7 @@
1923
* Add `ToValue` instances for `Word`, `Text`, `Value`,
2024
`Scientific`, list (i.e. `[]`), the unit type (i.e. `()`),
2125
* Add `text` and `shortText` for value construction.
22-
26+
2327

2428
## 0.2.4.0 -- 2023-06-27
2529

Setup.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import Distribution.Simple
2+
23
main = defaultMain

bench/Main.hs

Lines changed: 79 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
{-# LANGUAGE BangPatterns #-}
21
{-# LANGUAGE ScopedTypeVariables #-}
32
{-# LANGUAGE TypeApplications #-}
43

5-
import Gauge.Main (defaultMain,bgroup,bench,whnf)
4+
import Gauge.Main (bench, bgroup, defaultMain, whnf)
65

76
import Metrics1024 (encodedMetrics1024)
8-
import Twitter100 (encodedTwitter100,byteStringTwitter100)
9-
import Url100 (encodedUrl100,byteStringUrl100)
7+
import Twitter100 (byteStringTwitter100, encodedTwitter100)
8+
import Url100 (byteStringUrl100, encodedUrl100)
109

10+
import qualified Data.Aeson as Aeson
11+
import qualified Data.ByteString.Lazy as LBS
1112
import qualified Data.Bytes as Bytes
1213
import qualified Data.Bytes.Builder as BLDR
1314
import qualified Data.Bytes.Chunks as Chunks
14-
import qualified Data.ByteString.Lazy as LBS
1515
import qualified Json as J
1616
import qualified Json.Smile as Smile
17-
import qualified Data.Aeson as Aeson
1817

1918
main :: IO ()
2019
main = do
@@ -31,58 +30,80 @@ main = do
3130
Nothing -> fail "aeson failed to decode twitter-100"
3231
Just (v :: Aeson.Value) -> pure v
3332
defaultMain
34-
[ bgroup "json"
35-
[ bgroup "twitter"
36-
[ bgroup "100"
37-
[ bench "decode" $ whnf
38-
(\b -> J.decode (Bytes.fromByteArray b))
39-
encodedTwitter100
40-
, bench "encode" $ whnf
41-
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
42-
valueTwitter100
43-
, bench "encode-smile" $ whnf
44-
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
45-
valueTwitter100
46-
]
47-
]
48-
, bgroup "url"
49-
[ bgroup "100"
50-
[ bench "decode" $ whnf
51-
(\b -> J.decode (Bytes.fromByteArray b))
52-
encodedUrl100
53-
, bench "encode" $ whnf
54-
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
55-
valueUrl100
56-
, bench "encode-smile" $ whnf
57-
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
58-
valueUrl100
59-
]
60-
]
61-
, bgroup "metrics"
62-
[ bgroup "1024"
63-
[ bench "encode" $ whnf
64-
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
65-
valueMetrics1024
66-
, bench "encode-smile" $ whnf
67-
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
68-
valueMetrics1024
69-
]
70-
]
71-
]
72-
, bgroup "aeson"
73-
[ bgroup "twitter"
74-
[ bgroup "100"
75-
[ bench "decode"
76-
(whnf (Aeson.decodeStrict' @Aeson.Value) byteStringTwitter100)
77-
, bench "encode" $ whnf
78-
(\v -> LBS.length (Aeson.encode v))
79-
aesonValueTwitter100
80-
]
33+
[ bgroup
34+
"json"
35+
[ bgroup
36+
"twitter"
37+
[ bgroup
38+
"100"
39+
[ bench "decode" $
40+
whnf
41+
(\b -> J.decode (Bytes.fromByteArray b))
42+
encodedTwitter100
43+
, bench "encode" $
44+
whnf
45+
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
46+
valueTwitter100
47+
, bench "encode-smile" $
48+
whnf
49+
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
50+
valueTwitter100
51+
]
52+
]
53+
, bgroup
54+
"url"
55+
[ bgroup
56+
"100"
57+
[ bench "decode" $
58+
whnf
59+
(\b -> J.decode (Bytes.fromByteArray b))
60+
encodedUrl100
61+
, bench "encode" $
62+
whnf
63+
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
64+
valueUrl100
65+
, bench "encode-smile" $
66+
whnf
67+
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
68+
valueUrl100
69+
]
70+
]
71+
, bgroup
72+
"metrics"
73+
[ bgroup
74+
"1024"
75+
[ bench "encode" $
76+
whnf
77+
(\v -> Chunks.length (BLDR.run 128 (J.encode v)))
78+
valueMetrics1024
79+
, bench "encode-smile" $
80+
whnf
81+
(\v -> Chunks.length (BLDR.run 128 (Smile.encode v)))
82+
valueMetrics1024
83+
]
84+
]
8185
]
82-
, bgroup "url"
83-
[ bgroup "100"
84-
[ bench "decode" (whnf (Aeson.decodeStrict' @Aeson.Value) byteStringUrl100)
85-
]
86+
, bgroup
87+
"aeson"
88+
[ bgroup
89+
"twitter"
90+
[ bgroup
91+
"100"
92+
[ bench
93+
"decode"
94+
(whnf (Aeson.decodeStrict' @Aeson.Value) byteStringTwitter100)
95+
, bench "encode" $
96+
whnf
97+
(\v -> LBS.length (Aeson.encode v))
98+
aesonValueTwitter100
99+
]
100+
]
101+
, bgroup
102+
"url"
103+
[ bgroup
104+
"100"
105+
[ bench "decode" (whnf (Aeson.decodeStrict' @Aeson.Value) byteStringUrl100)
106+
]
107+
]
86108
]
87-
]
88109
]

common/Metrics1024.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
{-# LANGUAGE QuasiQuotes #-}
3+
34
module Metrics1024
45
( encodedMetrics1024
56
, byteStringMetrics1024
67
) where
78

89
import Data.ByteString (ByteString)
9-
import Data.ByteString.Short (ShortByteString,toShort)
10+
import Data.ByteString.Short (ShortByteString, toShort)
1011
import Data.Primitive (ByteArray)
1112
import Data.Text.Encoding (encodeUtf8)
1213
import NeatInterpolation (text)
1314

14-
import qualified Data.Primitive as PM
1515
import qualified Data.ByteString.Short.Internal as BSS
16+
import qualified Data.Primitive as PM
1617

17-
shortByteStringToByteArray :: ShortByteString -> ByteArray
18+
shortByteStringToByteArray :: ShortByteString -> ByteArray
1819
shortByteStringToByteArray (BSS.SBS x) = PM.ByteArray x
1920

2021
encodedMetrics1024 :: ByteArray
2122
encodedMetrics1024 =
2223
shortByteStringToByteArray (toShort byteStringMetrics1024)
2324

2425
byteStringMetrics1024 :: ByteString
25-
byteStringMetrics1024 = encodeUtf8
26-
[text|
26+
byteStringMetrics1024 =
27+
encodeUtf8
28+
[text|
2729
[ {"@id":"1E7nJ7Ki1ei1mSOuy","@service":"npm","@historical":false,"@timestamp":"2022-02-01T15:10:00Z","@row":"1","organization.acronym":"nyc","agent.type":"freight","host.address":"192.0.2.43","host.ip":"192.0.2.43","host.model":"unknown","host.model_oid":"1.3.6.1.4.1.14988.1","host.vendor":"mikrotik","component.cpu.utilization":0,"component.name":"","host.hostname":"NYC-S75-APT4215"}
2830
, {"@id":"1E7nJ7SponsUYpH9l","@service":"npm","@historical":false,"@timestamp":"2022-02-01T15:10:00Z","@row":"2","organization.acronym":"nyc","agent.type":"freight","host.address":"192.0.2.43","host.ip":"192.0.2.43","host.model":"unknown","host.model_oid":"1.3.6.1.4.1.14988.1","host.vendor":"mikrotik","component.cpu.utilization":0,"component.name":"","host.hostname":"NYC-S75-APT4215"}
2931
, {"@id":"1E7nJ7VyTvxK5KDVi","@service":"npm","@historical":false,"@timestamp":"2022-02-01T15:10:00Z","@row":"3","organization.acronym":"nyc","agent.type":"freight","host.address":"192.0.2.43","host.ip":"192.0.2.43","host.model":"unknown","host.model_oid":"1.3.6.1.4.1.14988.1","host.vendor":"mikrotik","component.cpu.utilization":0,"component.name":"","host.hostname":"NYC-S75-APT4215"}

common/Person.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
{-# LANGUAGE QuasiQuotes #-}
3+
34
module Person
45
( encodedPerson
56
, encodedFlattenedPerson
67
) where
78

89
import Data.ByteString (ByteString)
9-
import Data.ByteString.Short (ShortByteString,toShort)
10+
import Data.ByteString.Short (ShortByteString, toShort)
1011
import Data.Primitive (ByteArray)
1112
import Data.Text.Encoding (encodeUtf8)
1213
import NeatInterpolation (text)
1314

14-
import qualified Data.Primitive as PM
1515
import qualified Data.ByteString.Short.Internal as BSS
16+
import qualified Data.Primitive as PM
1617

17-
shortByteStringToByteArray :: ShortByteString -> ByteArray
18+
shortByteStringToByteArray :: ShortByteString -> ByteArray
1819
shortByteStringToByteArray (BSS.SBS x) = PM.ByteArray x
1920

2021
encodedPerson :: ByteArray
@@ -26,8 +27,9 @@ encodedFlattenedPerson =
2627
shortByteStringToByteArray (toShort byteStringFlattenedPerson)
2728

2829
byteStringPerson :: ByteString
29-
byteStringPerson = encodeUtf8
30-
[text|
30+
byteStringPerson =
31+
encodeUtf8
32+
[text|
3133
{ "name": "bilbo"
3234
, "occupation":
3335
{ "name": "burglar"
@@ -39,13 +41,13 @@ byteStringPerson = encodeUtf8
3941
|]
4042

4143
byteStringFlattenedPerson :: ByteString
42-
byteStringFlattenedPerson = encodeUtf8
43-
[text|
44+
byteStringFlattenedPerson =
45+
encodeUtf8
46+
[text|
4447
{ "name": "bilbo"
4548
, "occupation.name": "burglar"
4649
, "occupation.start": "2022-05-30"
4750
, "height": 124
4851
, "favorites": ["adventures","lunch"]
4952
}
5053
|]
51-

common/Twitter100.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
{-# LANGUAGE QuasiQuotes #-}
3+
34
module Twitter100
45
( encodedTwitter100
56
, byteStringTwitter100
67
) where
78

89
import Data.ByteString (ByteString)
9-
import Data.ByteString.Short (ShortByteString,toShort)
10+
import Data.ByteString.Short (ShortByteString, toShort)
1011
import Data.Primitive (ByteArray)
1112
import Data.Text.Encoding (encodeUtf8)
1213
import NeatInterpolation (text)
1314

14-
import qualified Data.Primitive as PM
1515
import qualified Data.ByteString.Short.Internal as BSS
16+
import qualified Data.Primitive as PM
1617

17-
shortByteStringToByteArray :: ShortByteString -> ByteArray
18+
shortByteStringToByteArray :: ShortByteString -> ByteArray
1819
shortByteStringToByteArray (BSS.SBS x) = PM.ByteArray x
1920

2021
encodedTwitter100 :: ByteArray
2122
encodedTwitter100 =
2223
shortByteStringToByteArray (toShort byteStringTwitter100)
2324

2425
byteStringTwitter100 :: ByteString
25-
byteStringTwitter100 = encodeUtf8
26-
[text|
26+
byteStringTwitter100 =
27+
encodeUtf8
28+
[text|
2729
{
2830
"completed_in": 1.000000,
2931
"max_id": 30121530767708160,
@@ -1864,4 +1866,3 @@ byteStringTwitter100 = encodeUtf8
18641866
"since_id_str": "0"
18651867
}
18661868
|]
1867-

common/Url100.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
{-# LANGUAGE QuasiQuotes #-}
3+
34
module Url100
45
( encodedUrl100
56
, byteStringUrl100
67
) where
78

89
import Data.ByteString (ByteString)
9-
import Data.ByteString.Short (ShortByteString,toShort)
10+
import Data.ByteString.Short (ShortByteString, toShort)
1011
import Data.Primitive (ByteArray)
1112
import Data.Text.Encoding (encodeUtf8)
1213
import NeatInterpolation (text)
1314

14-
import qualified Data.Primitive as PM
1515
import qualified Data.ByteString.Short.Internal as BSS
16+
import qualified Data.Primitive as PM
1617

17-
shortByteStringToByteArray :: ShortByteString -> ByteArray
18+
shortByteStringToByteArray :: ShortByteString -> ByteArray
1819
shortByteStringToByteArray (BSS.SBS x) = PM.ByteArray x
1920

2021
encodedUrl100 :: ByteArray
2122
encodedUrl100 =
2223
shortByteStringToByteArray (toShort byteStringUrl100)
2324

2425
byteStringUrl100 :: ByteString
25-
byteStringUrl100 = encodeUtf8
26-
[text|
26+
byteStringUrl100 =
27+
encodeUtf8
28+
[text|
2729
[ "https://balance.example.com/aunt.htm"
2830
, "http://anger.example.com/"
2931
, "https://www.example.edu/basket/branch#boat"
@@ -126,5 +128,3 @@ byteStringUrl100 = encodeUtf8
126128
, "http://attack.example.org/"
127129
]
128130
|]
129-
130-

0 commit comments

Comments
 (0)