Skip to content

Commit 7a4482b

Browse files
committed
chore: remove time stuff
1 parent b94e9b5 commit 7a4482b

File tree

6 files changed

+31
-382
lines changed

6 files changed

+31
-382
lines changed

megaparsec-utils.cabal

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ source-repository head
3131

3232
library
3333
exposed-modules:
34-
Text.Megaparsec.Time
3534
Text.Megaparsec.Utils
3635
other-modules:
3736
Paths_megaparsec_utils
@@ -44,15 +43,13 @@ library
4443
, megaparsec >=9.0 && <10
4544
, parser-combinators >=1.0 && <2
4645
, text >=2.0 && <3
47-
, time >=1.10 && <2
4846
, uuid >=1.3 && <2
4947
default-language: Haskell2010
5048

5149
test-suite megaparsec-utils-test
5250
type: exitcode-stdio-1.0
5351
main-is: Spec.hs
5452
other-modules:
55-
Text.Megaparsec.TimeSpec
5653
Text.Megaparsec.UtilsSpec
5754
Paths_megaparsec_utils
5855
hs-source-dirs:
@@ -67,7 +64,5 @@ test-suite megaparsec-utils-test
6764
, megaparsec-utils
6865
, parser-combinators >=1.0 && <2
6966
, text >=2.0 && <3
70-
, time >=1.10 && <2
7167
, uuid >=1.3 && <2
7268
default-language: Haskell2010
73-
build-tool-depends: hspec-discover:hspec-discover == 2.*

package.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ dependencies:
2828
- megaparsec >= 9.0 && < 10
2929
- parser-combinators >= 1.0 && < 2
3030
- text >= 2.0 && < 3
31-
- time >= 1.10 && < 2
3231
- uuid >= 1.3 && < 2
3332

3433
ghc-options:
@@ -47,7 +46,6 @@ library:
4746

4847
tests:
4948
megaparsec-utils-test:
50-
defaults: sol/hpack-defaults@hspec-cabal-new
5149
main: Spec.hs
5250
source-dirs: test
5351
ghc-options:

src/Text/Megaparsec/Time.hs

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

src/Text/Megaparsec/Utils.hs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import Text.Megaparsec.Char (
4949
hexDigitChar,
5050
string',
5151
)
52+
import Text.Read (readMaybe)
5253

5354
-- | Parse a case-insensitive human-readable boolean, including C-style numbers
5455
-- and English yes-no.
@@ -97,22 +98,30 @@ occurrences
9798
-> Parsec e String [a]
9899
occurrences = some . try . occurrence . try
99100

100-
-- | Parse a positive number with decimals.
101+
-- | Parse a positive number, with or without decimals prefixed by a @.@.
101102
posDecNumParser
102103
:: Ord e
103-
=> Parsec e String Double
104+
=> Read a
105+
=> Parsec e String a
104106
posDecNumParser = do
105107
num <- some digitChar
106-
den <- maybe "" ("." <>) <$> optional (char '.' >> some digitChar)
108+
dec <- maybe "" ("." <>) <$> optional (char '.' >> some digitChar)
109+
110+
let str = num <> dec
107111

108-
return . read $ num <> den
112+
maybe (fail ("could not read from input: " <> str)) pure (readMaybe str)
109113

110114
-- | Parse a positive integer.
111115
posNumParser
112116
:: Ord e
113117
=> Read a
114118
=> Parsec e String a
115-
posNumParser = read <$> some digitChar
119+
posNumParser = do
120+
digits <- some digitChar
121+
maybe
122+
(fail ("could not read from digits: " <> digits))
123+
pure
124+
(readMaybe digits)
116125

117126
-- | Parse an integer, without any space between minus sign and digits.
118127
numParser
@@ -132,7 +141,7 @@ parsecToJSONParser
132141
-- ^ Parser.
133142
-> (Value -> Parser a)
134143
parsecToJSONParser n p =
135-
withText n $ either (fail . errorBundlePretty) pure . runParser p n . T.unpack
144+
withText n (either (fail . errorBundlePretty) pure . runParser p n . T.unpack)
136145

137146
-- | Convert a 'Parsec' parser into a 'ReadS' parser. Useful for defining 'Read'
138147
-- instances with 'Text.Megaparsec'.
@@ -152,4 +161,7 @@ uuidParser = do
152161
part4 <- replicateM 4 hexDigitChar <* char '-'
153162
part5 <- replicateM 12 hexDigitChar
154163

155-
pure . fromJust . U.fromString $ intercalate "-" [part1, part2, part3, part4, part5]
164+
pure
165+
(fromJust
166+
(U.fromString
167+
(intercalate "-" [part1, part2, part3, part4, part5])))

0 commit comments

Comments
 (0)