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

Commit 30f989b

Browse files
committed
Keep using -precise instead of -decimals
1 parent 8f6f82b commit 30f989b

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"dependencies": {
2525
"purescript-const": "^4.0.0",
2626
"purescript-datetime": "^4.0.0",
27-
"purescript-decimals": "^4.0.0",
2827
"purescript-functors": "^3.0.0",
2928
"purescript-lists": "^5.0.0",
3029
"purescript-ordered-collections": "^1.0.0",
3130
"purescript-parsing": "^5.0.1",
3231
"purescript-partial": "^2.0.0",
32+
"purescript-precise": "purescript-contrib/purescript-precise#45ed556854d314b41097837bdbced744bc11818b",
3333
"purescript-prelude": "^4.0.1",
3434
"purescript-strings": "^4.0.0",
3535
"purescript-strongcheck": "^4.1.1",

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"build": "pulp build -- --censor-lib --strict",
66
"test": "pulp test"
77
},
8-
"dependencies": {
9-
"decimal.js": "7.1.1"
10-
},
118
"devDependencies": {
129
"pulp": "^12.3.0",
1310
"purescript": "^0.12.0",

src/Text/Markdown/SlamDown/Parser/Inline.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import Data.Bifunctor (lmap)
1515
import Data.Char.Unicode (isAlphaNum)
1616
import Data.Const (Const(..))
1717
import Data.DateTime as DT
18-
import Data.Decimal as D
1918
import Data.Either (Either(..))
2019
import Data.Enum (toEnum)
2120
import Data.Foldable (elem)
2221
import Data.Functor.Compose (Compose(..))
22+
import Data.HugeNum as HN
2323
import Data.Int as Int
2424
import Data.List as L
2525
import Data.Maybe as M
@@ -94,7 +94,7 @@ hash = void $ PS.string "#"
9494
type TextParserKit
9595
= { plainText P.Parser String String
9696
, natural P.Parser String Int
97-
, decimal P.Parser String D.Decimal
97+
, decimal P.Parser String HN.HugeNum
9898
, numericPrefix P.Parser String Unit
9999
}
100100

@@ -486,7 +486,7 @@ parseTextBox isPlainText eta template =
486486
M.Nothing
487487
pure M.Nothing
488488

489-
D.fromString (ms <> "." <> M.fromMaybe "" ns)
489+
HN.fromString (ms <> "." <> M.fromMaybe "" ns)
490490
# M.maybe (P.fail "Failed parsing decimal") pure
491491

492492
parsePlainTextValue =

src/Text/Markdown/SlamDown/Pretty.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import Prelude
77

88
import Data.Array as A
99
import Data.DateTime as DT
10-
import Data.Decimal as D
1110
import Data.Foldable (fold, elem)
1211
import Data.Functor.Compose (Compose)
12+
import Data.HugeNum as HN
1313
import Data.Identity (Identity(..))
1414
import Data.List as L
1515
import Data.Maybe as M
@@ -117,8 +117,8 @@ prettyPrintTextBoxValue t =
117117
case t of
118118
SD.PlainText (Identity def) → def
119119
SD.Numeric (Identity def) →
120-
let s = D.toString def in
121-
M.fromMaybe s $ S.stripSuffix (S.Pattern ".") $ D.toString def
120+
let s = HN.toString def in
121+
M.fromMaybe s $ S.stripSuffix (S.Pattern ".") $ HN.toString def
122122
SD.Date (Identity def) → prettyPrintDate def
123123
SD.Time prec (Identity def) → prettyPrintTime prec def
124124
SD.DateTime prec (Identity def) → prettyPrintDateTime prec def
@@ -175,7 +175,7 @@ prettyPrintTextBox t =
175175
prettyPrintDefault =
176176
case _ of
177177
SD.PlainText def → prettyPrintExpr identity identity def
178-
SD.Numeric def → prettyPrintExpr identity D.toString def
178+
SD.Numeric def → prettyPrintExpr identity HN.toString def
179179
SD.Date def → prettyPrintExpr identity prettyPrintDate def
180180
SD.Time prec def → prettyPrintExpr identity (prettyPrintTime prec) def
181181
SD.DateTime prec def → prettyPrintExpr identity (prettyPrintDateTime prec) def

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Text.Markdown.SlamDown.Syntax.TextBox
88
import Prelude
99

1010
import Data.DateTime as DT
11-
import Data.Decimal as D
1211
import Data.Eq (class Eq1)
12+
import Data.HugeNum as HN
1313
import Data.Identity (Identity(..))
1414
import Data.Newtype (unwrap)
1515
import Data.Ord (class Ord1)
@@ -41,7 +41,7 @@ instance coarbitraryTimePrecision ∷ SCA.Coarbitrary TimePrecision where
4141

4242
data TextBox f
4343
= PlainText (f String)
44-
| Numeric (f D.Decimal)
44+
| Numeric (f HN.HugeNum)
4545
| Date (f DT.Date)
4646
| Time TimePrecision (f DT.Time)
4747
| DateTime TimePrecision (f DT.DateTime)
@@ -62,23 +62,23 @@ traverseTextBox eta = case _ of
6262
Time prec def → Time prec <$> eta def
6363
DateTime prec def → DateTime prec <$> eta def
6464

65-
instance showTextBox ∷ (Functor f, Show (f String), Show (f D.Decimal), Show (f DT.Time), Show (f DT.Date), Show (f DT.DateTime)) Show (TextBox f) where
65+
instance showTextBox ∷ (Functor f, Show (f String), Show (f HN.HugeNum), Show (f DT.Time), Show (f DT.Date), Show (f DT.DateTime)) Show (TextBox f) where
6666
show = case _ of
6767
PlainText def → "(PlainText " <> show def <> ")"
6868
Numeric def → "(Numeric " <> show def <> ")"
6969
Date def → "(Date " <> show def <> ")"
7070
Time prec def → "(Time " <> show prec <> " " <> show def <> ")"
7171
DateTime prec def → "(DateTime " <> show prec <> " " <> show def <> ")"
7272

73-
derive instance eqTextBox ∷ (Functor f, Eq (f String), Eq (f D.Decimal), Eq (f DT.Time), Eq (f DT.Date), Eq (f DT.DateTime), Eq1 f) Eq (TextBox f)
74-
derive instance ordTextBox ∷ (Functor f, Ord (f String), Ord (f D.Decimal), Ord (f DT.Time), Ord (f DT.Date), Ord (f DT.DateTime), Ord1 f) Ord (TextBox f)
73+
derive instance eqTextBox ∷ (Functor f, Eq (f String), Eq (f HN.HugeNum), Eq (f DT.Time), Eq (f DT.Date), Eq (f DT.DateTime), Eq1 f) Eq (TextBox f)
74+
derive instance ordTextBox ∷ (Functor f, Ord (f String), Ord (f HN.HugeNum), Ord (f DT.Time), Ord (f DT.Date), Ord (f DT.DateTime), Ord1 f) Ord (TextBox f)
7575

7676
instance arbitraryTextBox ∷ (Functor f, SCA.Arbitrary (f String), SCA.Arbitrary (f Number), SCA.Arbitrary (f ADT.ArbTime), SCA.Arbitrary (f ADT.ArbDate), SCA.Arbitrary (f ADT.ArbDateTime)) SCA.Arbitrary (TextBox f) where
7777
arbitrary = do
7878
i ← Gen.chooseInt 0 5
7979
case i of
8080
0PlainText <$> SCA.arbitrary
81-
1Numeric <<< map D.fromNumber <$> SCA.arbitrary
81+
1Numeric <<< map HN.fromNumber <$> SCA.arbitrary
8282
2Date <<< map ADT.runArbDate <$> SCA.arbitrary
8383
3Time <$> SCA.arbitrary <*> (map (eraseMillis <<< ADT.runArbTime) <$> SCA.arbitrary)
8484
4DateTime <$> SCA.arbitrary <*> (map (DT.modifyTime eraseMillis <<< ADT.runArbDateTime) <$> SCA.arbitrary)
@@ -88,7 +88,7 @@ instance coarbitraryTextBox ∷ (Functor f, SCA.Coarbitrary (f String), SCA.Coar
8888
coarbitrary =
8989
case _ of
9090
PlainText d -> SCA.coarbitrary d
91-
Numeric d -> SCA.coarbitrary $ D.toNumber <$> d
91+
Numeric d -> SCA.coarbitrary $ HN.toNumber <$> d
9292
Date d -> SCA.coarbitrary (ADT.ArbDate <$> d)
9393
Time prec d -> do
9494
_ ← SCA.coarbitrary prec

test/src/Test/Main.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import Control.Monad.Trampoline as Trampoline
77
import Data.Array as A
88
import Data.Char as CH
99
import Data.DateTime as DT
10-
import Data.Decimal as D
1110
import Data.Either (Either(..), isLeft)
1211
import Data.Enum (toEnum)
12+
import Data.HugeNum as HN
1313
import Data.Identity as ID
1414
import Data.List as L
1515
import Data.Maybe as M
@@ -234,7 +234,7 @@ static = do
234234
, textBox: \_ t →
235235
case t of
236236
SD.PlainText _ → pure $ SD.PlainText $ pure "Evaluated plain text!"
237-
SD.Numeric _ → pure $ SD.Numeric $ pure $ D.fromNumber 42.0
237+
SD.Numeric _ → pure $ SD.Numeric $ pure $ HN.fromNumber 42.0
238238
SD.Date _ → pure $ SD.Date $ pure $ unsafeDate 1992 7 30
239239
SD.Time (prec@SD.Minutes) _ → pure $ SD.Time prec $ pure $ unsafeTime 4 52 0
240240
SD.Time (prec@SD.Seconds) _ → pure $ SD.Time prec $ pure $ unsafeTime 4 52 10

0 commit comments

Comments
 (0)