From f3cb639c07814771b011ad28429c8a0f0603a353 Mon Sep 17 00:00:00 2001 From: Brent Yorgey <byorgey@gmail.com> Date: Mon, 27 May 2024 12:51:59 -0500 Subject: [PATCH] Update FromJSON TickNumber instance to match ToJSON instance --- src/swarm-engine/Swarm/Game/Tick.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/swarm-engine/Swarm/Game/Tick.hs b/src/swarm-engine/Swarm/Game/Tick.hs index ed657d757c..bf4b92de40 100644 --- a/src/swarm-engine/Swarm/Game/Tick.hs +++ b/src/swarm-engine/Swarm/Game/Tick.hs @@ -17,11 +17,14 @@ import Swarm.Util.WindowedCounter (Offsettable (..)) -- | A newtype representing a count of ticks (typically since the -- start of a game). newtype TickNumber = TickNumber {getTickNumber :: Int64} - deriving (Eq, Ord, Show, Read, Generic, FromJSON) + deriving (Eq, Ord, Show, Read, Generic) instance ToJSON TickNumber where toJSON = A.genericToJSON (A.defaultOptions {A.unwrapUnaryRecords = True}) +instance FromJSON TickNumber where + parseJSON = A.genericParseJSON (A.defaultOptions {A.unwrapUnaryRecords = True}) + -- | Add an offset to a 'TickNumber'. addTicks :: Int -> TickNumber -> TickNumber addTicks i (TickNumber n) = TickNumber $ n + fromIntegral i