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

Commit 22d9efc

Browse files
committed
Rename Object to Map
1 parent a5b61df commit 22d9efc

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

src/Data/Json/Extended.purs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module Data.Json.Extended
1717
, time
1818
, interval
1919
, objectId
20-
, object
21-
, object'
20+
, map
21+
, map'
2222
, array
2323

2424
, renderEJson
@@ -30,7 +30,9 @@ module Data.Json.Extended
3030
, getType
3131
) where
3232

33-
import Prelude
33+
import Prelude hiding (map)
34+
35+
import Data.Functor as F
3436

3537
import Control.Lazy as Lazy
3638

@@ -79,15 +81,15 @@ roll
7981
roll =
8082
EJson
8183
<<< Mu.roll
82-
<<< map getEJson
84+
<<< F.map getEJson
8385

8486
unroll
8587
EJson
8688
Sig.EJsonF EJson
8789
unroll =
8890
getEJson
8991
>>> Mu.unroll
90-
>>> map EJson
92+
>>> F.map EJson
9193

9294
head EJson Sig.EJsonF (Mu.Mu Sig.EJsonF)
9395
head = Mu.unroll <<< getEJson
@@ -205,11 +207,11 @@ objectId = roll <<< Sig.ObjectId
205207
array Array EJson EJson
206208
array = roll <<< Sig.Array
207209

208-
object Map.Map EJson EJson EJson
209-
object = roll <<< Sig.Object <<< A.fromFoldable <<< Map.toList
210+
map Map.Map EJson EJson EJson
211+
map = roll <<< Sig.Map <<< A.fromFoldable <<< Map.toList
210212

211-
object' SM.StrMap EJson EJson
212-
object' = roll <<< Sig.Object <<< map go <<< A.fromFoldable <<< SM.toList
213+
map' SM.StrMap EJson EJson
214+
map' = roll <<< Sig.Map <<< F.map go <<< A.fromFoldable <<< SM.toList
213215
where
214216
go (T.Tuple a b) = T.Tuple (string a) b
215217

src/Data/Json/Extended/Signature/Core.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data EJsonF a
2929
| Interval String
3030
| ObjectId String
3131
| Array (Array a)
32-
| Object (Array (Tuple a a))
32+
| Map (Array (Tuple a a))
3333

3434
instance functorEJsonFFunctor EJsonF where
3535
map f x =
@@ -45,7 +45,7 @@ instance functorEJsonF ∷ Functor EJsonF where
4545
Interval i → Interval i
4646
ObjectId oid → ObjectId oid
4747
Array xs → Array $ f <$> xs
48-
Object xs → Object $ BF.bimap f f <$> xs
48+
Map xs → Map $ BF.bimap f f <$> xs
4949

5050
instance eq1EJsonFEq1 EJsonF where
5151
eq1 Null Null = true
@@ -61,7 +61,7 @@ instance eq1EJsonF ∷ Eq1 EJsonF where
6161
eq1 (Interval a) (Interval b) = a == b
6262
eq1 (ObjectId a) (ObjectId b) = a == b
6363
eq1 (Array xs) (Array ys) = xs == ys
64-
eq1 (Object xs) (Object ys) =
64+
eq1 (Map xs) (Map ys) =
6565
let
6666
xs' = L.fromFoldable xs
6767
ys' = L.fromFoldable ys
@@ -138,7 +138,7 @@ instance ord1EJsonF ∷ Ord1 EJsonF where
138138
compare1 _ (Array _) = GT
139139
compare1 (Array _) _ = LT
140140

141-
compare1 (Object a) (Object b) = compare (Map.fromFoldable a) (Map.fromFoldable b)
141+
compare1 (Map a) (Map b) = compare (Map.fromFoldable a) (Map.fromFoldable b)
142142

143143
getType a. EJsonF a T.EJsonType
144144
getType = case _ of
@@ -153,4 +153,4 @@ getType = case _ of
153153
Interval _ → T.Interval
154154
ObjectId _ → T.ObjectId
155155
Array _ → T.Array
156-
Object _ → T.Object
156+
Map _ → T.Map

src/Data/Json/Extended/Signature/Gen.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ arbitraryEJsonFWithKeyGen keyGen rec =
3939
Gen.oneOf (pure Null)
4040
[ arbitraryBaseEJsonF
4141
, Array <$> Gen.arrayOf rec
42-
, Object <$> do
42+
, Map <$> do
4343
keys ← distinctArrayOf keyGen
4444
vals ← Gen.vectorOf (A.length keys) rec
4545
pure $ A.zip keys vals

src/Data/Json/Extended/Signature/Json.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ encodeJsonEJsonF rec asKey x =
3636
Interval str → JS.jsonSingletonObject "$interval" $ encodeJson str
3737
ObjectId str → JS.jsonSingletonObject "$oid" $ encodeJson str
3838
Array xs → encodeJson $ rec <$> xs
39-
Object xs → JS.jsonSingletonObject "$obj" $ encodeJson $ asStrMap xs
39+
Map xs → JS.jsonSingletonObject "$obj" $ encodeJson $ asStrMap xs
4040
where
4141
tuple
4242
T.Tuple a a
@@ -137,7 +137,7 @@ decodeJsonEJsonF rec makeKey =
137137
SM.StrMap a
138138
EJsonF a
139139
strMapObject =
140-
Object
140+
Map
141141
<<< A.fromFoldable
142142
<<< map (\(T.Tuple k v) → T.Tuple (makeKey k) v)
143143
<<< SM.toList

src/Data/Json/Extended/Signature/Parse.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ parseEJsonF rec =
258258
, Interval <$> taggedLiteral "INTERVAL"
259259
, ObjectId <$> taggedLiteral "OID"
260260
, Array <<< A.fromFoldable <$> squares (commaSep rec)
261-
, Object <<< A.fromFoldable <$> braces (commaSep parseAssignment)
261+
, Map <<< A.fromFoldable <$> braces (commaSep parseAssignment)
262262
]
263263

264264
where

src/Data/Json/Extended/Signature/Render.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ renderEJsonF rec d =
3131
Interval str → tagged "INTERVAL" str
3232
ObjectId str → tagged "OID" str
3333
Array ds → squares $ commaSep ds
34-
Object ds → braces $ renderPairs ds
34+
Map ds → braces $ renderPairs ds
3535
where
3636
tagged
3737
String

src/Data/Json/Extended/Type.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data EJsonType
1414
| Interval
1515
| ObjectId
1616
| Array
17-
| Object
17+
| Map
1818

1919
derive instance eqEJsonTypeEq EJsonType
2020
derive instance ordEJsonTypeOrd EJsonType
@@ -31,4 +31,4 @@ instance showEJsonType ∷ Show EJsonType where
3131
show Interval = "Interval"
3232
show ObjectId = "ObjectId"
3333
show Array = "Array"
34-
show Object = "Object"
34+
show Map = "Map"

0 commit comments

Comments
 (0)