Skip to content

Commit da419d7

Browse files
committed
Build with prettyprinter
1 parent 994040e commit da419d7

File tree

6 files changed

+31
-24
lines changed

6 files changed

+31
-24
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
ghc: ["9.8.1", "9.6.3", "9.4.8", "9.2.8", "9.0.2", "8.10.7"]
20+
ghc: ["9.8.2", "9.6.6"]
2121
os: [ubuntu-latest, macOS-latest, windows-latest]
2222
exclude:
2323
- os: windows-latest

hw-json.cabal

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ maintainer: [email protected]
1212
copyright: 2016-2021 John Ky
1313
license: BSD-3-Clause
1414
license-file: LICENSE
15-
tested-with: GHC == 9.2.2, GHC == 9.0.2, GHC == 8.10.7, GHC == 8.8.4, GHC == 8.6.5
15+
tested-with: GHC == 9.8.2, GHC == 9.6.6
1616
build-type: Simple
1717
extra-source-files: README.md
1818
corpus/5000B.json
@@ -40,7 +40,6 @@ flag sse42
4040
common base { build-depends: base >= 4.11 && < 5 }
4141

4242
common aeson { build-depends: aeson >= 2.0 && < 2.3 }
43-
common ansi-wl-pprint { build-depends: ansi-wl-pprint >= 0.6.8.2 && < 2 }
4443
common array { build-depends: array >= 0.5 && < 0.6 }
4544
common attoparsec { build-depends: attoparsec >= 0.13 && < 0.15 }
4645
common attoparsec-aeson { build-depends: attoparsec-aeson >= 2 && < 3 }
@@ -69,13 +68,19 @@ common hw-simd { build-depends: hw-simd >=
6968
common lens { build-depends: lens >= 4 && < 6 }
7069
common mmap { build-depends: mmap >= 0.5 && < 0.6 }
7170
common optparse-applicative { build-depends: optparse-applicative >= 0.14 && < 0.19 }
71+
common prettyprinter { build-depends: prettyprinter >= 1 && < 2 }
7272
common scientific { build-depends: scientific >= 0.3.6.2 && < 0.4 }
7373
common text { build-depends: text >= 1.2 && < 3 }
7474
common transformers { build-depends: transformers >= 0.4 && < 0.7 }
7575
common unordered-containers { build-depends: unordered-containers >= 0.2 && < 0.3 }
7676
common vector { build-depends: vector >= 0.12 && < 0.14 }
7777
common word8 { build-depends: word8 >= 0.1 && < 0.2 }
7878

79+
if os(darwin)
80+
common hw-json-simd { }
81+
else
82+
common hw-json-simd { build-depends: hw-json-simd >= 0.1.0.2 && < 0.2 }
83+
7984
common config
8085
default-language: Haskell2010
8186
ghc-options: -Wall -O2 -msse4.2
@@ -91,7 +96,6 @@ common hw-json
9196
library
9297
import: base, config
9398
, aeson
94-
, ansi-wl-pprint
9599
, attoparsec
96100
, attoparsec-aeson
97101
, bits-extra
@@ -108,6 +112,7 @@ library
108112
, hw-rankselect-base
109113
, hw-simd
110114
, mmap
115+
, prettyprinter
111116
, scientific
112117
, text
113118
, vector
@@ -120,7 +125,6 @@ library
120125
HaskellWorks.Data.Json.Internal.CharLike
121126
HaskellWorks.Data.Json.Internal.Doc
122127
HaskellWorks.Data.Json.Internal.Index
123-
HaskellWorks.Data.Json.Internal.Orphans
124128
HaskellWorks.Data.Json.Internal.PartialIndex
125129
HaskellWorks.Data.Json.Internal.Slurp
126130
HaskellWorks.Data.Json.Internal.Standard.Cursor.Token
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
module HaskellWorks.Data.Json.Internal.Doc
2-
( hEncloseSep
2+
( hEncloseSep,
3+
text,
4+
red,
5+
dullgreen,
6+
cyan,
37
) where
48

5-
import Text.PrettyPrint.ANSI.Leijen
9+
import Prettyprinter
610

7-
hEncloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc
11+
hEncloseSep :: Doc a -> Doc a -> Doc a -> [Doc a] -> Doc a
812
hEncloseSep l r s ds = case ds of
913
[] -> l <> r
1014
[d] -> l <> d <> r
1115
_ -> hcat (zipWith (<>) (l : repeat s) ds) <> r
16+
17+
text :: String -> Doc a
18+
text = pretty
19+
20+
red :: Doc a -> Doc a
21+
red = id
22+
23+
dullgreen :: Doc a -> Doc a
24+
dullgreen = id
25+
26+
cyan :: Doc a -> Doc a
27+
cyan = id

src/HaskellWorks/Data/Json/Internal/Orphans.hs

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

src/HaskellWorks/Data/Json/LightJson.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import HaskellWorks.Data.RankSelect.Base.Select1
3131
import HaskellWorks.Data.TreeCursor
3232
import HaskellWorks.Data.Uncons
3333
import Prelude hiding (drop)
34-
import Text.PrettyPrint.ANSI.Leijen
34+
import Prettyprinter
3535

3636
import qualified Data.ByteString as BS
3737
import qualified Data.ByteString.Unsafe as BSU

src/HaskellWorks/Data/Json/PartialValue.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import Data.String
2525
import Data.Text (Text)
2626
import HaskellWorks.Data.Bits.BitWise
2727
import HaskellWorks.Data.Json.Internal.Doc
28-
import HaskellWorks.Data.Json.Internal.Orphans ()
2928
import HaskellWorks.Data.Json.Internal.PartialIndex
3029
import HaskellWorks.Data.Json.Internal.Value
3130
import HaskellWorks.Data.Json.Standard.Cursor.Generic
@@ -39,7 +38,7 @@ import HaskellWorks.Data.RankSelect.Base.Rank0
3938
import HaskellWorks.Data.RankSelect.Base.Rank1
4039
import HaskellWorks.Data.RankSelect.Base.Select1
4140
import Prelude hiding (drop)
42-
import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))
41+
import Prettyprinter
4342

4443
import qualified Data.Attoparsec.ByteString.Char8 as ABC
4544
import qualified Data.ByteString as BS
@@ -150,10 +149,9 @@ instance Pretty (Mini JsonPartialValue) where
150149
pretty mjpv = case mjpv of
151150
Mini (JsonPartialString s ) -> dullgreen (text (show s))
152151
Mini (JsonPartialNumber n ) -> cyan (text (show n))
153-
Mini (JsonPartialObject [] ) -> text "{}"
154152
Mini (JsonPartialObject kvs ) -> case kvs of
155-
(_:_:_:_:_:_:_:_:_:_:_:_:_) -> text "{" <> prettyKvs kvs <> text ", ..}"
156153
[] -> text "{}"
154+
(_:_:_:_:_:_:_:_:_:_:_:_:_) -> text "{" <> prettyKvs kvs <> text ", ..}"
157155
_ -> text "{" <> prettyKvs kvs <> text "}"
158156
Mini (JsonPartialArray [] ) -> text "[]"
159157
Mini (JsonPartialArray vs ) | vs `atLeastSize` 11 -> text "[" <> nest 2 (prettyVs (Micro `map` take 10 vs)) <> text ", ..]"

0 commit comments

Comments
 (0)