summaryrefslogtreecommitdiff
path: root/lib/Badges.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Badges.hs')
-rw-r--r--lib/Badges.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Badges.hs b/lib/Badges.hs
index 5da2643..c1a17b3 100644
--- a/lib/Badges.hs
+++ b/lib/Badges.hs
@@ -1,11 +1,14 @@
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DerivingStrategies #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecordWildCards #-}
-- | module defining Badge types and utility functions
module Badges where
+import Control.DeepSeq (NFData)
import Data.Aeson (Options (fieldLabelModifier, sumEncoding),
SumEncoding (UntaggedValue), ToJSON (toJSON),
defaultOptions, genericToJSON, (.=))
@@ -27,10 +30,10 @@ data BadgeArea =
, areaWidth :: Double
, areaHeight :: Double
}
- deriving (Ord, Eq, Generic, Show)
+ deriving (Ord, Eq, Generic, Show, NFData)
newtype BadgeToken = BadgeToken Text
- deriving (Eq, Ord, Show)
+ deriving newtype (Eq, Ord, Show, NFData)
instance ToJSON BadgeArea where
toJSON = genericToJSON defaultOptions
@@ -46,7 +49,7 @@ parseToken text = if text =~ ("^[a-zA-Z0-9]{50}$" :: Text)
else Nothing
data Badge = Badge BadgeToken BadgeArea
- deriving (Ord, Eq, Generic, Show)
+ deriving (Ord, Eq, Generic, Show, NFData)
instance ToJSON Badge where
toJSON (Badge token area) = A.object $ case area of