aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-23 13:57:41 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-23 13:57:41 +0000
commit1c0ff2e51ba225617b17d7c26b64c89021cf8e83 (patch)
treebd3a330a9cd219487deabbc5fedd2619df5265b6 /spec
parent32fd365fb546e7e2ad195b575be4bca457cba6e9 (diff)
downloadthermoprint-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.hs5
-rw-r--r--spec/src/Thermoprint/Identifiers.hs10
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
31import Data.Text (Text) 31import Data.Text (Text)
32 32
33import Data.Typeable (Typeable)
33import GHC.Generics (Generic) 34import GHC.Generics (Generic)
35import Control.DeepSeq (NFData)
34 36
35import Data.Proxy (Proxy(..)) 37import Data.Proxy (Proxy(..))
36 38
37import Control.Exception (Exception) 39import Control.Exception (Exception)
38import Data.Typeable (Typeable)
39 40
40instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where 41instance (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
57data PrintingError = UnknownError 58data PrintingError = UnknownError
58 deriving (Typeable, Generic, Show, Read, FromJSON, ToJSON, Exception) 59 deriving (Typeable, Generic, NFData, Show, Read, FromJSON, ToJSON, Exception)
59 60
60type DraftTitle = Text 61type 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
11import Data.Typeable (Typeable)
12import GHC.Generics (Generic)
13import Control.DeepSeq (NFData)
14
11import Servant.API (ToText, FromText) 15import Servant.API (ToText, FromText)
12import Data.Aeson (FromJSON, ToJSON) 16import Data.Aeson (FromJSON, ToJSON)
13 17
14newtype PrinterId = PrinterId Integer 18newtype 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
17newtype JobId = JobId Integer 21newtype 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
20newtype DraftId = DraftId Integer 24newtype 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
23castId :: (Integral a, Enum b) => a -> b 27castId :: (Integral a, Enum b) => a -> b
24castId = toEnum . fromInteger . toInteger 28castId = toEnum . fromInteger . toInteger