Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit eeede6d

Browse files
authored
Merge pull request #1 from garyb/paulyoung-paulyoung/0.12
Improve constraints, bump -functors for `Compose` fix, remove StrongCheck/generated stuff
2 parents f8a0b98 + 72a802f commit eeede6d

File tree

8 files changed

+66
-508
lines changed

8 files changed

+66
-508
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ import Text.Markdown.SlamDown.Pretty
3434
Module documentation is [published on
3535
Pursuit](http://pursuit.purescript.org/packages/purescript-markdown).
3636

37-
### Tests
38-
39-
The tests use [purescript-strongcheck](http://github.com/purescript-contrib/purescript-strongcheck) to verify that an arbitrary `SlamDown` document can be rendered as a `String` and then parsed to a `SlamDown` equal to the original.
40-
4137
## Features
4238

4339
In general, SlamDown is a subset of [CommonMark](http://spec.commonmark.org/), supporting the following features:

bower.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@
2424
"dependencies": {
2525
"purescript-const": "^4.0.0",
2626
"purescript-datetime": "^4.0.0",
27-
"purescript-functors": "^3.0.0",
27+
"purescript-functors": "^3.0.1",
2828
"purescript-lists": "^5.0.0",
2929
"purescript-ordered-collections": "^1.0.0",
3030
"purescript-parsing": "^5.0.1",
3131
"purescript-partial": "^2.0.0",
3232
"purescript-precise": "^3.0.1",
3333
"purescript-prelude": "^4.0.1",
3434
"purescript-strings": "^4.0.0",
35-
"purescript-strongcheck": "^4.1.1",
3635
"purescript-unicode": "^4.0.1",
3736
"purescript-validation": "^4.0.0"
37+
},
38+
"devDependencies": {
39+
"purescript-assert": "^4.0.0"
3840
}
3941
}

src/Text/Markdown/SlamDown/Syntax.purs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,28 @@ module Text.Markdown.SlamDown.Syntax
99

1010
import Prelude
1111

12+
import Data.Eq (class Eq1)
1213
import Data.List as L
13-
import Test.StrongCheck.Arbitrary as SCA
14-
import Test.StrongCheck.Gen as Gen
15-
14+
import Data.Ord (class Ord1)
1615
import Text.Markdown.SlamDown.Syntax.Block (Block(..), CodeBlockType(..), ListType(..)) as SDB
1716
import Text.Markdown.SlamDown.Syntax.FormField (class Value, Expr(..), FormField, FormFieldP(..), TextBox(..), TimePrecision(..), getLiteral, getUnevaluated, renderValue, stringValue, transFormField, transTextBox, traverseFormField, traverseTextBox) as SDF
1817
import Text.Markdown.SlamDown.Syntax.Inline (Inline(..), LinkTarget(..)) as SDI
1918

2019
-- | `SlamDownP` is the type of SlamDown abstract syntax trees which take values in `a`.
21-
data SlamDownP a = SlamDown (L.List (SDB.Block a))
20+
newtype SlamDownP a = SlamDown (L.List (SDB.Block a))
2221

2322
type SlamDown = SlamDownP String
2423

25-
instance functorSlamDownPFunctor SlamDownP where
26-
map f (SlamDown bs) = SlamDown (map f <$> bs)
24+
derive instance functorSlamDownPFunctor SlamDownP
2725

2826
instance showSlamDownP ∷ (Show a) Show (SlamDownP a) where
2927
show (SlamDown bs) = "(SlamDown " <> show bs <> ")"
3028

31-
derive instance eqSlamDownP ∷ (Eq a, Ord a) Eq (SlamDownP a)
32-
derive instance ordSlamDownP ∷ (Eq a, Ord a) Ord (SlamDownP a)
33-
34-
instance semigroupSlamDownPSemigroup (SlamDownP a) where
35-
append (SlamDown bs1) (SlamDown bs2) = SlamDown (bs1 <> bs2)
29+
derive newtype instance eqSlamDownPEq a Eq (SlamDownP a)
30+
derive instance eq1SlamDownPEq1 SlamDownP
3631

37-
instance monoidSlamDownPMonoid (SlamDownP a) where
38-
mempty = SlamDown mempty
32+
derive newtype instance ordSlamDownPOrd a Ord (SlamDownP a)
33+
derive instance ord1SlamDownPOrd1 SlamDownP
3934

40-
instance arbitrarySlamDownP(SCA.Arbitrary a, Eq a) SCA.Arbitrary (SlamDownP a) where
41-
arbitrary = SlamDown <<< L.fromFoldable <$> Gen.arrayOf SCA.arbitrary
35+
derive newtype instance semigroupSlamDownPSemigroup (SlamDownP a)
36+
derive newtype instance monoidSlamDownPMonoid (SlamDownP a)

src/Text/Markdown/SlamDown/Syntax/Block.purs

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ module Text.Markdown.SlamDown.Syntax.Block
66

77
import Prelude
88

9+
import Data.Eq (class Eq1)
910
import Data.List as L
10-
11-
import Test.StrongCheck.Arbitrary as SCA
12-
import Test.StrongCheck.Gen as Gen
13-
11+
import Data.Ord (class Ord1)
1412
import Text.Markdown.SlamDown.Syntax.Inline (Inline)
1513

1614
data Block a
@@ -22,18 +20,9 @@ data Block a
2220
| LinkReference String String
2321
| Rule
2422

25-
instance functorBlockFunctor Block where
26-
map f x =
27-
case x of
28-
Paragraph is → Paragraph (map f <$> is)
29-
Header n is → Header n (map f <$> is)
30-
Blockquote bs → Blockquote (map f <$> bs)
31-
Lst ty bss → Lst ty (map (map f) <$> bss)
32-
CodeBlock ty ss → CodeBlock ty ss
33-
LinkReference l uri → LinkReference l uri
34-
RuleRule
23+
derive instance functorBlockFunctor Block
3524

36-
instance showBlock(Show a) Show (Block a) where
25+
instance showBlockShow a Show (Block a) where
3726
show (Paragraph is) = "(Paragraph " <> show is <> ")"
3827
show (Header n is) = "(Header " <> show n <> " " <> show is <> ")"
3928
show (Blockquote bs) = "(Blockquote " <> show bs <> ")"
@@ -42,24 +31,10 @@ instance showBlock ∷ (Show a) ⇒ Show (Block a) where
4231
show (LinkReference l uri) = "(LinkReference " <> show l <> " " <> show uri <> ")"
4332
show Rule = "Rule"
4433

45-
derive instance eqBlock ∷ (Eq a, Ord a) Eq (Block a)
46-
derive instance ordBlock ∷ (Ord a) Ord (Block a)
47-
48-
-- | Nota bene: this does not generate any recursive structure
49-
instance arbitraryBlock ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (Block a) where
50-
arbitrary = do
51-
k ← Gen.chooseInt 0 6
52-
case k of
53-
0Paragraph <$> listOf SCA.arbitrary
54-
1Header <$> SCA.arbitrary <*> listOf SCA.arbitrary
55-
2 → pure $ Blockquote L.Nil
56-
3Lst <$> SCA.arbitrary <*> listOf (pure L.Nil)
57-
4CodeBlock <$> SCA.arbitrary <*> listOf SCA.arbitrary
58-
5LinkReference <$> SCA.arbitrary <*> SCA.arbitrary
59-
_ → pure Rule
60-
61-
listOf f a. (Monad f) Gen.GenT f a Gen.GenT f (L.List a)
62-
listOf = map L.fromFoldable <<< Gen.arrayOf
34+
derive instance eqBlockEq a Eq (Block a)
35+
derive instance eq1BlockEq1 Block
36+
derive instance ordBlockOrd a Ord (Block a)
37+
derive instance ord1BlockOrd1 Block
6338

6439
data ListType
6540
= Bullet String
@@ -72,11 +47,6 @@ instance showListType ∷ Show ListType where
7247
derive instance eqListTypeEq ListType
7348
derive instance ordListTypeOrd ListType
7449

75-
instance arbitraryListTypeSCA.Arbitrary ListType where
76-
arbitrary = do
77-
b ← SCA.arbitrary
78-
if b then Bullet <$> SCA.arbitrary else Ordered <$> SCA.arbitrary
79-
8050
data CodeBlockType
8151
= Indented
8252
| Fenced Boolean String
@@ -87,8 +57,3 @@ instance showCodeBlockType ∷ Show CodeBlockType where
8757

8858
derive instance eqCodeBlockTypeEq CodeBlockType
8959
derive instance ordCodeBlockTypeOrd CodeBlockType
90-
91-
instance arbitraryCodeBlockTypeSCA.Arbitrary CodeBlockType where
92-
arbitrary = do
93-
b ← SCA.arbitrary
94-
if b then pure Indented else Fenced <$> SCA.arbitrary <*> SCA.arbitrary

0 commit comments

Comments
 (0)