diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-23 13:57:41 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-23 13:57:41 +0000 |
commit | 1c0ff2e51ba225617b17d7c26b64c89021cf8e83 (patch) | |
tree | bd3a330a9cd219487deabbc5fedd2619df5265b6 /spec | |
parent | 32fd365fb546e7e2ad195b575be4bca457cba6e9 (diff) | |
download | thermoprint-1c0ff2e51ba225617b17d7c26b64c89021cf8e83.tar thermoprint-1c0ff2e51ba225617b17d7c26b64c89021cf8e83.tar.gz thermoprint-1c0ff2e51ba225617b17d7c26b64c89021cf8e83.tar.bz2 thermoprint-1c0ff2e51ba225617b17d7c26b64c89021cf8e83.tar.xz thermoprint-1c0ff2e51ba225617b17d7c26b64c89021cf8e83.zip |
NFData instances
Diffstat (limited to 'spec')
-rw-r--r-- | spec/src/Thermoprint/API.hs | 5 | ||||
-rw-r--r-- | spec/src/Thermoprint/Identifiers.hs | 10 |
2 files changed, 10 insertions, 5 deletions
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) | |||
30 | 30 | ||
31 | import Data.Text (Text) | 31 | import Data.Text (Text) |
32 | 32 | ||
33 | import Data.Typeable (Typeable) | ||
33 | import GHC.Generics (Generic) | 34 | import GHC.Generics (Generic) |
35 | import Control.DeepSeq (NFData) | ||
34 | 36 | ||
35 | import Data.Proxy (Proxy(..)) | 37 | import Data.Proxy (Proxy(..)) |
36 | 38 | ||
37 | import Control.Exception (Exception) | 39 | import Control.Exception (Exception) |
38 | import Data.Typeable (Typeable) | ||
39 | 40 | ||
40 | instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where | 41 | instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where |
41 | toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) | 42 | toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) |
@@ -55,7 +56,7 @@ data JobStatus = Queued PrinterId | |||
55 | deriving (Generic, Show, Read, FromJSON, ToJSON) | 56 | deriving (Generic, Show, Read, FromJSON, ToJSON) |
56 | 57 | ||
57 | data PrintingError = UnknownError | 58 | data PrintingError = UnknownError |
58 | deriving (Typeable, Generic, Show, Read, FromJSON, ToJSON, Exception) | 59 | deriving (Typeable, Generic, NFData, Show, Read, FromJSON, ToJSON, Exception) |
59 | 60 | ||
60 | type DraftTitle = Text | 61 | type DraftTitle = Text |
61 | 62 | ||
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 | |||
8 | , castId | 8 | , castId |
9 | ) where | 9 | ) where |
10 | 10 | ||
11 | import Data.Typeable (Typeable) | ||
12 | import GHC.Generics (Generic) | ||
13 | import Control.DeepSeq (NFData) | ||
14 | |||
11 | import Servant.API (ToText, FromText) | 15 | import Servant.API (ToText, FromText) |
12 | import Data.Aeson (FromJSON, ToJSON) | 16 | import Data.Aeson (FromJSON, ToJSON) |
13 | 17 | ||
14 | newtype PrinterId = PrinterId Integer | 18 | newtype PrinterId = PrinterId Integer |
15 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) | 19 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) |
16 | 20 | ||
17 | newtype JobId = JobId Integer | 21 | newtype JobId = JobId Integer |
18 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) | 22 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) |
19 | 23 | ||
20 | newtype DraftId = DraftId Integer | 24 | newtype DraftId = DraftId Integer |
21 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) | 25 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON, Typeable, Generic, NFData) |
22 | 26 | ||
23 | castId :: (Integral a, Enum b) => a -> b | 27 | castId :: (Integral a, Enum b) => a -> b |
24 | castId = toEnum . fromInteger . toInteger | 28 | castId = toEnum . fromInteger . toInteger |