Skip to content

Commit a7d607f

Browse files
committed
Use quickcheck-instances for Text and UTCTime
It removes two orphan instances which were long-present inside api-tools
1 parent ce72967 commit a7d607f

3 files changed

Lines changed: 3 additions & 19 deletions

File tree

api-tools.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Library
9696
containers >= 0.5 && < 0.8 ,
9797
deepseq >= 1.1 && < 1.6 ,
9898
lens >= 3.8.7 && < 5.4 ,
99+
quickcheck-instances < 0.4 ,
99100
regex-base >= 0.93 && < 0.95 ,
100101
regex-tdfa >= 1.1.0 && < 1.4 ,
101102
safe >= 0.3.3 && < 0.4 ,

src/Data/API/Time.hs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Data.Time
1919

2020
import GHC.Stack
2121
import Test.QuickCheck as QC
22+
import Test.QuickCheck.Instances.Time ()
2223

2324
utcFormat :: String
2425
utcFormat = "%Y-%m-%dT%H:%M:%SZ"
@@ -136,19 +137,3 @@ unsafeParseDay :: HasCallStack => T.Text -> Day
136137
unsafeParseDay t = fromMaybe (error msg) (parseDay t)
137138
where
138139
msg = "unsafeParseDay: unable to parse: " ++ T.unpack t
139-
140-
141-
-- TODO: use a more arbitrary instance (quickcheck-instances?)
142-
-- (in particular, there are no subsecond-resolution times here)
143-
instance QC.Arbitrary UTCTime where
144-
arbitrary = QC.oneof
145-
[ QC.elements [mk "2010-01-01T00:00:00Z"
146-
, mk "2013-05-27T19:13:50Z"
147-
, mk "2011-07-20T22:04:00Z"
148-
, mk "2012-02-02T15:45:11Z"
149-
, mk "2009-11-12T20:57:54Z"
150-
, mk "2000-10-28T21:03:24Z"
151-
, mk "1965-03-10T09:23:01Z"
152-
]]
153-
where
154-
mk = unsafeParseUTC

src/Data/API/Types.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import qualified Data.Text as T
5252
import qualified Data.Text.Encoding as T
5353
import qualified Data.ByteString.Char8 as B
5454
import Test.QuickCheck as QC
55+
import Test.QuickCheck.Instances.Text ()
5556
import Control.Applicative
5657
import qualified Data.ByteString.Base64 as B64
5758
import Language.Haskell.TH
@@ -334,9 +335,6 @@ instance ToJSON Binary where
334335
instance FromJSON Binary where
335336
parseJSON = withBinary "Binary" return
336337

337-
instance QC.Arbitrary T.Text where
338-
arbitrary = T.pack <$> QC.arbitrary
339-
340338
instance QC.Arbitrary Binary where
341339
arbitrary = Binary <$> B.pack <$> QC.arbitrary
342340

0 commit comments

Comments
 (0)