summaryrefslogtreecommitdiff
path: root/haskell
diff options
context:
space:
mode:
authorJulien Dessaux2023-07-19 22:04:46 +0200
committerJulien Dessaux2023-07-19 22:04:46 +0200
commitb76382337697d180f81a8bf0da2cd978b1613aba (patch)
treec451c3ebbf221d0c46bef7f8068593400619d3d3 /haskell
parent[haskell] refactoring (diff)
downloadspacetraders-b76382337697d180f81a8bf0da2cd978b1613aba.tar.gz
spacetraders-b76382337697d180f81a8bf0da2cd978b1613aba.tar.bz2
spacetraders-b76382337697d180f81a8bf0da2cd978b1613aba.zip
[haskell] Fixed models' serialization
Diffstat (limited to 'haskell')
-rw-r--r--haskell/src/SpaceTraders/Model/Contract.hs16
-rw-r--r--haskell/src/SpaceTraders/Model/Route.hs10
-rw-r--r--haskell/src/SpaceTraders/Model/System.hs12
-rw-r--r--haskell/src/SpaceTraders/Model/Waypoint.hs8
4 files changed, 23 insertions, 23 deletions
diff --git a/haskell/src/SpaceTraders/Model/Contract.hs b/haskell/src/SpaceTraders/Model/Contract.hs
index 742062e..a0bebcc 100644
--- a/haskell/src/SpaceTraders/Model/Contract.hs
+++ b/haskell/src/SpaceTraders/Model/Contract.hs
@@ -34,14 +34,14 @@ instance FromJSON Contract where
<*> o .: "fulfilled"
<*> o .: "terms"
instance ToJSON Contract where
- toEncoding (Contract a i ty e d fa fu te) = pairs ( "accepted" .= a
- <> "id" .= i
- <> "type" .= ty
- <> "expiration" .= e
- <> "deadlineToAccept" .= d
- <> "factionSymbol" .= fa
- <> "fulfilled" .= fu
- <> "terms" .= te )
+ toJSON (Contract a i ty e d fa fu te) = object [ "accepted" .= a
+ , "id" .= i
+ , "type" .= ty
+ , "expiration" .= e
+ , "deadlineToAccept" .= d
+ , "factionSymbol" .= fa
+ , "fulfilled" .= fu
+ , "terms" .= te ]
data Delivery = Delivery { destinationSymbol :: T.Text
, tradeSymbol :: T.Text
diff --git a/haskell/src/SpaceTraders/Model/Route.hs b/haskell/src/SpaceTraders/Model/Route.hs
index 9681214..670c953 100644
--- a/haskell/src/SpaceTraders/Model/Route.hs
+++ b/haskell/src/SpaceTraders/Model/Route.hs
@@ -32,8 +32,8 @@ instance FromJSON RouteEndpoint where
<*> o .: "x"
<*> o .: "y"
instance ToJSON RouteEndpoint where
- toEncoding (RouteEndpoint t s ss xx yy) = pairs ( "type" .= t
- <> "symbol" .= s
- <> "systemSymbol" .= ss
- <> "x" .= xx
- <> "y" .= yy )
+ toJSON (RouteEndpoint t s ss xx yy) = object [ "type" .= t
+ , "symbol" .= s
+ , "systemSymbol" .= ss
+ , "x" .= xx
+ , "y" .= yy ]
diff --git a/haskell/src/SpaceTraders/Model/System.hs b/haskell/src/SpaceTraders/Model/System.hs
index dacd27a..0092ef5 100644
--- a/haskell/src/SpaceTraders/Model/System.hs
+++ b/haskell/src/SpaceTraders/Model/System.hs
@@ -29,9 +29,9 @@ instance FromJSON System where
<*> o .: "y"
<*> o .: "waypoints"
instance ToJSON System where
- toEncoding (System ss s t xx yy w) = pairs ( "sectorSymbol" .= ss
- <> "symbol" .= s
- <> "type" .= t
- <> "x" .= xx
- <> "y" .= yy
- <> "waypoints" .= w )
+ toJSON (System ss s t xx yy w) = object [ "sectorSymbol" .= ss
+ , "symbol" .= s
+ , "type" .= t
+ , "x" .= xx
+ , "y" .= yy
+ , "waypoints" .= w ]
diff --git a/haskell/src/SpaceTraders/Model/Waypoint.hs b/haskell/src/SpaceTraders/Model/Waypoint.hs
index d18cc11..458df21 100644
--- a/haskell/src/SpaceTraders/Model/Waypoint.hs
+++ b/haskell/src/SpaceTraders/Model/Waypoint.hs
@@ -22,7 +22,7 @@ instance FromJSON Waypoint where
<*> o .: "x"
<*> o .: "y"
instance ToJSON Waypoint where
- toEncoding (Waypoint s t xx yy) = pairs ( "symbol" .= s
- <> "type" .= t
- <> "x" .= xx
- <> "y" .= yy )
+ toJSON (Waypoint s t xx yy) = object [ "symbol" .= s
+ , "type" .= t
+ , "x" .= xx
+ , "y" .= yy ]