Skip to content

Commit d1767f0

Browse files
authored
Added Data instances (#5)
1 parent 1d53f19 commit d1767f0

File tree

5 files changed

+132
-168
lines changed

5 files changed

+132
-168
lines changed

markup-parse.cabal

Lines changed: 82 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: markup-parse
3-
version: 0.2.0.0
3+
version: 0.2.1.0
44
license: BSD-3-Clause
55
license-file: LICENSE
66
copyright: Copyright, Tony Day, 2023-
@@ -11,78 +11,100 @@ homepage: https://github.com/tonyday567/markup-parse#readme
1111
bug-reports: https://github.com/tonyday567/markup-parse/issues
1212
synopsis: A markup parser.
1313
description:
14-
A markup parser and printer, from and to strict bytestrings, optimised for speed.
14+
A markup parser and printer, from and to strict bytestrings, optimised for speed.
15+
1516
build-type: Simple
1617
tested-with:
17-
, GHC == 9.6.7
18-
, GHC == 9.8.4
19-
, GHC == 9.10.2
20-
, GHC == 9.12.2
18+
ghc ==9.6.7
19+
ghc ==9.8.4
20+
ghc ==9.10.2
21+
ghc ==9.12.2
22+
2123
extra-doc-files:
22-
ChangeLog.md
23-
other/*.html
24-
other/*.svg
25-
readme.md
24+
ChangeLog.md
25+
other/*.html
26+
other/*.svg
27+
readme.md
2628

2729
source-repository head
28-
type: git
29-
location: https://github.com/tonyday567/markup-parse
30+
type: git
31+
location: https://github.com/tonyday567/markup-parse
3032

3133
common ghc-options-exe-stanza
32-
ghc-options:
33-
-fforce-recomp
34-
-funbox-strict-fields
35-
-rtsopts
36-
-threaded
34+
ghc-options:
35+
-fforce-recomp
36+
-funbox-strict-fields
37+
-rtsopts
38+
-threaded
3739

3840
common ghc-options-stanza
39-
ghc-options:
40-
-Wall
41-
-Wcompat
42-
-Wincomplete-record-updates
43-
-Wincomplete-uni-patterns
44-
-Wredundant-constraints
41+
ghc-options:
42+
-Wall
43+
-Wcompat
44+
-Wincomplete-record-updates
45+
-Wincomplete-uni-patterns
46+
-Wredundant-constraints
47+
48+
common ghc2024-additions
49+
default-extensions:
50+
DataKinds
51+
DerivingStrategies
52+
DisambiguateRecordFields
53+
ExplicitNamespaces
54+
GADTs
55+
LambdaCase
56+
MonoLocalBinds
57+
RoleAnnotations
4558

46-
common ghc2021-stanza
47-
default-language: GHC2021
59+
common ghc2024-stanza
60+
if impl(ghc >=9.10)
61+
default-language:
62+
GHC2024
63+
else
64+
import: ghc2024-additions
65+
default-language:
66+
GHC2021
4867

4968
library
50-
import: ghc-options-stanza
51-
import: ghc2021-stanza
52-
hs-source-dirs: src
53-
build-depends:
54-
, base >=4.14 && <5
55-
, bytestring >=0.11.3 && <0.13
56-
, containers >=0.6 && <0.9
57-
, deepseq >=1.4 && <1.6
58-
, flatparse >=0.3.5 && <0.6
59-
, string-interpolate >=0.3 && <0.4
60-
, these >=1.1 && <1.3
61-
exposed-modules:
62-
MarkupParse
63-
MarkupParse.Internal.FlatParse
69+
import: ghc-options-stanza
70+
import: ghc2024-stanza
71+
hs-source-dirs: src
72+
build-depends:
73+
base >=4.14 && <5,
74+
bytestring >=0.11.3 && <0.13,
75+
containers >=0.6 && <0.9,
76+
deepseq >=1.4 && <1.6,
77+
flatparse >=0.3.5 && <0.6,
78+
string-interpolate >=0.3 && <0.4,
79+
these >=1.1 && <1.3,
80+
81+
exposed-modules:
82+
MarkupParse
83+
MarkupParse.Internal.FlatParse
6484

6585
test-suite doctests
66-
import: ghc2021-stanza
67-
main-is: doctests.hs
68-
hs-source-dirs: test
69-
build-depends:
70-
, base >=4.14 && <5
71-
, doctest-parallel >=0.3 && <0.5
72-
ghc-options: -threaded
73-
type: exitcode-stdio-1.0
86+
import: ghc2024-stanza
87+
main-is: doctests.hs
88+
hs-source-dirs: test
89+
build-depends:
90+
base >=4.14 && <5,
91+
doctest-parallel >=0.3 && <0.5,
92+
93+
ghc-options: -threaded
94+
type: exitcode-stdio-1.0
7495

7596
test-suite markup-parse-diff
76-
import: ghc-options-exe-stanza
77-
import: ghc-options-stanza
78-
import: ghc2021-stanza
79-
main-is: markup-parse-diff.hs
80-
hs-source-dirs: app
81-
build-depends:
82-
, base >=4.14 && <5
83-
, bytestring >=0.11.3 && <0.13
84-
, markup-parse
85-
, tasty >=1.2 && <1.6
86-
, tasty-golden >=2.3.1.1 && <2.4
87-
, Diff >=1.0 && <1.1
88-
type: exitcode-stdio-1.0
97+
import: ghc-options-exe-stanza
98+
import: ghc-options-stanza
99+
import: ghc2024-stanza
100+
main-is: markup-parse-diff.hs
101+
hs-source-dirs: app
102+
build-depends:
103+
Diff >=1.0 && <1.1,
104+
base >=4.14 && <5,
105+
bytestring >=0.11.3 && <0.13,
106+
markup-parse,
107+
tasty >=1.2 && <1.6,
108+
tasty-golden >=2.3.1.1 && <2.4,
109+
110+
type: exitcode-stdio-1.0

markup-parse.org

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,35 @@
77

88
* Development
99

10-
#+begin_src haskell :results output :exports both
10+
#+begin_src haskell-ng :results output :exports both
1111
:r
12-
:set prompt "> "
1312
:set -Wno-type-defaults
1413
:set -Wno-name-shadowing
1514
:set -XOverloadedStrings
1615
:set -XTemplateHaskell
1716
:set -XQuasiQuotes
1817
import Control.Monad
1918
import MarkupParse
20-
import MarkupParse.FlatParse
21-
import MarkupParse.Patch
19+
import MarkupParse.Internal.FlatParse
2220
import Data.ByteString qualified as B
2321
import Data.ByteString.Char8 qualified as C
2422
import Data.Map.Strict qualified as Map
2523
import Data.Function
2624
import FlatParse.Basic hiding (take)
2725
import Data.String.Interpolate
28-
import Data.TreeDiff
2926
import Control.Monad
3027
bs <- B.readFile "other/line.svg"
3128
C.length bs
3229
#+end_src
3330

3431
#+RESULTS:
35-
: Preprocessing library for markup-parse-0.1.1..
36-
: GHCi, version 9.6.2: https://www.haskell.org/ghc/ :? for help
37-
: [1 of 3] Compiling MarkupParse.FlatParse ( src/MarkupParse/FlatParse.hs, interpreted )
38-
: [2 of 3] Compiling MarkupParse ( src/MarkupParse.hs, interpreted )
39-
: [3 of 3] Compiling MarkupParse.Patch ( src/MarkupParse/Patch.hs, interpreted )
40-
: Ok, three modules loaded.
41-
: g
42-
: Ok, three modules loaded.
32+
: [1 of 2] Compiling MarkupParse.Internal.FlatParse ( src/MarkupParse/Internal/FlatParse.hs, interpreted ) [Flags changed]
33+
: Ok, two modules reloaded.
4334
: 7554
4435

4536
* Main Pipeline types
4637

47-
#+begin_src haskell :results output :exports both
38+
#+begin_src haskell-ng :results output :exports both
4839
:t tokenize Html
4940
:t gather Html
5041
:t normalize
@@ -62,30 +53,21 @@ C.length bs
6253
: tokenize Html >=> gather Html >=> (normalize >>> pure) >=> degather Html >=> (fmap (detokenize Html) >>> pure)
6354
: :: ByteString -> These [MarkupWarning] [ByteString]
6455

65-
Round trip equality
6656

67-
#+begin_src haskell :results output :exports both
57+
** tests
58+
*** Round trip equality
59+
60+
#+begin_src haskell-ng :results output :exports both
6861
m = markup_ Xml bs
6962
m == (markup_ Xml $ markdown_ Compact Xml m)
7063
#+end_src
7164

7265
#+RESULTS:
7366
: True
7467

75-
* MarkupParse.Patch
76-
77-
Obviously, patch doesn't belong here long-term but has been very useful in testing and development.
78-
79-
#+begin_src haskell :results output :exports both
80-
showPatch $ patch [1, 2, 3, 5] [0, 1, 2, 4, 6]
81-
#+end_src
82-
83-
#+RESULTS:
84-
: [+0, -3, +4, -5, +6]
68+
*** wiki diff test debug
8569

86-
* wiki diff test debug
87-
88-
#+begin_src haskell :results output :exports both
70+
#+begin_src haskell-ng :results output :exports both
8971
bs <- B.readFile "other/Parsing - Wikipedia.html"
9072
m = markup_ Html bs
9173
m == (markup_ Html $ markdown_ Compact Html m)
@@ -113,15 +95,9 @@ m == (markup_ Html $ markdown_ Compact Html m)
11395
[[https://hackage.haskell.org/package/XMLParser][XMLParser]] & [[https://hackage.haskell.org/package/hexml][hexml]] are parsec-based parsers.
11496

11597
* Performance
116-
98+
** perf
11799
The [[https://hackage.haskell.org/package/perf][perf]] library has been used to measure performance of the library.
118100

119-
`cabal bench` runs the default benchmarking:
120-
121-
#+begin_src sh :results output :exports both
122-
cabal bench
123-
#+end_src
124-
125101
#+RESULTS:
126102
#+begin_example
127103
Running 1 benchmarks...

0 commit comments

Comments
 (0)