summaryrefslogtreecommitdiff
path: root/haskell/src/SpaceTraders/Model/Route.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haskell/src/SpaceTraders/Model/Route.hs')
-rw-r--r--haskell/src/SpaceTraders/Model/Route.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/haskell/src/SpaceTraders/Model/Route.hs b/haskell/src/SpaceTraders/Model/Route.hs
index 959edff..9681214 100644
--- a/haskell/src/SpaceTraders/Model/Route.hs
+++ b/haskell/src/SpaceTraders/Model/Route.hs
@@ -7,7 +7,6 @@ module SpaceTraders.Model.Route
, RouteEndpoint(..)
) where
-import Control.Monad
import Data.Aeson
import Data.Time
import GHC.Generics
@@ -26,15 +25,15 @@ data RouteEndpoint = RouteEndpoint { routeEndpointType :: T.Text
, y :: Int
} deriving (Generic, Show)
instance FromJSON RouteEndpoint where
- parseJSON (Object o) = RouteEndpoint <$> o .: "type"
- <*> o .: "symbol"
- <*> o .: "systemSymbol"
- <*> o .: "x"
- <*> o .: "y"
- parseJSON _ = mzero
+ parseJSON = withObject "RouteEndpoint" $ \o ->
+ RouteEndpoint <$> o .: "type"
+ <*> o .: "symbol"
+ <*> o .: "systemSymbol"
+ <*> 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 )
+ <> "symbol" .= s
+ <> "systemSymbol" .= ss
+ <> "x" .= xx
+ <> "y" .= yy )