Skip to content

Commit b2960de

Browse files
Update support for json-syntax v3
1 parent 33fbd12 commit b2960de

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

monocle.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ library
186186
, tasty >= 1.4
187187
, tasty-hunit >= 0.10
188188
, template-haskell
189-
, text-short >= 0.1
190189
, text-time >= 0.3
191190
, th-env >= 0.1
192191
, time

src/Json/Extras.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
module Json.Extras (
55
-- * Data types
66
module Json,
7-
ShortText,
87

98
-- * Extras
109
decodeThrow,
@@ -16,8 +15,6 @@ module Json.Extras (
1615

1716
import Data.ByteString.Lazy qualified as LBS
1817
import Data.Bytes qualified as Bytes
19-
import Data.Text.Short (ShortText)
20-
import Data.Text.Short qualified as TextShort
2118
import Data.Text.Time qualified as TextTime
2219
import Data.Time.Clock (UTCTime)
2320
import Relude
@@ -30,7 +27,7 @@ decodeThrow dat = case decode (Bytes.fromByteString (from dat)) of
3027
Right v -> v
3128

3229
-- | 'getAttr' return an object value
33-
getAttr :: ShortText -> Json.Value -> Maybe Json.Value
30+
getAttr :: Text -> Json.Value -> Maybe Json.Value
3431
getAttr k v = case v of
3532
Json.Object xs -> getFirst $ foldMap getValue' xs
3633
_ -> Nothing
@@ -39,7 +36,7 @@ getAttr k v = case v of
3936
| key == k = First $ Just value
4037
| otherwise = First Nothing
4138

42-
getString :: Json.Value -> Maybe ShortText
39+
getString :: Json.Value -> Maybe Text
4340
getString v = case v of
4441
Json.String x -> pure x
4542
_ -> Nothing
@@ -51,5 +48,5 @@ getArray v = case v of
5148

5249
getDate :: Json.Value -> Maybe UTCTime
5350
getDate v = case v of
54-
Json.String t -> either (const Nothing) Just $ TextTime.parseUTCTimeOrError (TextShort.toText t)
51+
Json.String t -> either (const Nothing) Just $ TextTime.parseUTCTimeOrError t
5552
_ -> error "Not a date"

src/Monocle/Backend/Queries.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Data.List qualified
1010
import Data.Map qualified as Map
1111
import Data.Ord qualified
1212
import Data.String.Interpolate (i, iii)
13-
import Data.Text.Short qualified as TextShort
1413
import Data.Time (UTCTime (UTCTime), addDays, addGregorianMonthsClip, addGregorianYearsClip, secondsToNominalDiffTime)
1514
import Data.Time.Clock (secondsToDiffTime)
1615
import Data.Vector qualified as V
@@ -445,8 +444,8 @@ data FirstEvent = FirstEvent
445444
data JsonChangeEvent = JsonChangeEvent
446445
{ jceCreatedAt :: UTCTime
447446
, jceOnCreatedAt :: UTCTime
448-
, jceChangeId :: Json.ShortText
449-
, jceAuthor :: Json.ShortText
447+
, jceChangeId :: Text
448+
, jceAuthor :: Text
450449
}
451450

452451
decodeJsonChangeEvent :: Json.Value -> Maybe JsonChangeEvent
@@ -496,7 +495,7 @@ firstEventOnChanges = do
496495
let (createdAt, author) =
497496
-- If the event is older update the info
498497
if jceCreatedAt < feCreatedAt acc
499-
then (jceCreatedAt, from $ TextShort.toText jceAuthor)
498+
then (jceCreatedAt, from jceAuthor)
500499
else (feCreatedAt acc, feAuthor acc)
501500
in FirstEvent
502501
{ feChangeCreatedAt = jceOnCreatedAt

test/JsonDecode.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Criterion.Main
77
import Data.Aeson qualified as Aeson
88
import Data.ByteString.Lazy qualified as LBS
99
import Data.Bytes qualified as B
10-
import Data.Text.Short qualified as TextShort
1110
import Data.Text.Time qualified as T
1211
import Database.Bloodhound qualified as BH
1312
import Faker qualified
@@ -38,7 +37,7 @@ jsonPerf dat = do
3837
_ -> Nothing
3938
getDate :: Json.Value -> UTCTime
4039
getDate v = case v of
41-
Json.String t -> either (error "oops") id $ T.parseUTCTimeOrError (TextShort.toText t)
40+
Json.String t -> either (error "oops") id $ T.parseUTCTimeOrError t
4241
_ -> error "Not a date"
4342
toDuration :: Json.Value -> Maybe Pico
4443
toDuration v' = do

0 commit comments

Comments
 (0)