From 1c0ff2e51ba225617b17d7c26b64c89021cf8e83 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 23 Jan 2016 13:57:41 +0000 Subject: NFData instances --- spec/src/Thermoprint/API.hs | 5 +++-- spec/src/Thermoprint/Identifiers.hs | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'spec/src') diff --git a/spec/src/Thermoprint/API.hs b/spec/src/Thermoprint/API.hs index 00115f3..e3d4b61 100644 --- a/spec/src/Thermoprint/API.hs +++ b/spec/src/Thermoprint/API.hs @@ -30,12 +30,13 @@ import qualified Data.IntMap.Strict as IntMap (foldMapWithKey, singleton) import Data.Text (Text) +import Data.Typeable (Typeable) import GHC.Generics (Generic) +import Control.DeepSeq (NFData) import Data.Proxy (Proxy(..)) import Control.Exception (Exception) -import Data.Typeable (Typeable) instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) @@ -55,7 +56,7 @@ data JobStatus = Queued PrinterId deriving (Generic, Show, Read, FromJSON, ToJSON) data PrintingError = UnknownError - deriving (Typeable, Generic, Show, Read, FromJSON, ToJSON, Exception) + deriving (Typeable, Generic, NFData, Show, Read, FromJSON, ToJSON, Exception) type DraftTitle = Text diff --git a/spec/src/Thermoprint/Identifiers.hs b/spec/src/Thermoprint/Identifiers.hs index ee35e24..0d6f56a 100644 --- a/spec/src/Thermoprint/Identifiers.hs +++ b/spec/src/Thermoprint/Identifiers.hs @@ -8,17 +8,21 @@ module Thermoprint.Identifiers , castId ) where +import Data.Typeable (Typeable) +import GHC.Generics (Generic) +import Control.DeepSeq (NFData) + import Servant.API (ToText, FromText) import Data.Aeson (FromJSON, ToJSON) newtype PrinterId = PrinterId Integer - deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) + deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) newtype JobId = JobId Integer - deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) + deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) newtype DraftId = DraftId Integer - deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) + deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) castId :: (Integral a, Enum b) => a -> b castId = toEnum . fromInteger . toInteger -- cgit v1.2.3