diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-20 13:55:30 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-20 13:55:30 +0000 |
commit | edfadd543cfdc32177e8cc4392ea598afb12f7c0 (patch) | |
tree | bbe87cdba84dab9b6883f16197c5742cea8a4d9a /spec | |
parent | 64e3df81b31cc79b035913bda4d093e31bb1955a (diff) | |
download | thermoprint-edfadd543cfdc32177e8cc4392ea598afb12f7c0.tar thermoprint-edfadd543cfdc32177e8cc4392ea598afb12f7c0.tar.gz thermoprint-edfadd543cfdc32177e8cc4392ea598afb12f7c0.tar.bz2 thermoprint-edfadd543cfdc32177e8cc4392ea598afb12f7c0.tar.xz thermoprint-edfadd543cfdc32177e8cc4392ea598afb12f7c0.zip |
casting ids
Diffstat (limited to 'spec')
-rw-r--r-- | spec/src/Thermoprint/Identifiers.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/spec/src/Thermoprint/Identifiers.hs b/spec/src/Thermoprint/Identifiers.hs index 9608922..a2609a4 100644 --- a/spec/src/Thermoprint/Identifiers.hs +++ b/spec/src/Thermoprint/Identifiers.hs | |||
@@ -5,16 +5,20 @@ module Thermoprint.Identifiers | |||
5 | ( PrinterId(..) | 5 | ( PrinterId(..) |
6 | , JobId(..) | 6 | , JobId(..) |
7 | , DraftId(..) | 7 | , DraftId(..) |
8 | , castId | ||
8 | ) where | 9 | ) where |
9 | 10 | ||
10 | import Servant.API (ToText, FromText) | 11 | import Servant.API (ToText, FromText) |
11 | import Data.Aeson (FromJSON, ToJSON) | 12 | import Data.Aeson (FromJSON, ToJSON) |
12 | 13 | ||
13 | newtype PrinterId = PrinterId Integer | 14 | newtype PrinterId = PrinterId Integer |
14 | deriving (Show, Eq, Ord, Enum, FromText, ToText, FromJSON, ToJSON) | 15 | deriving (Show, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) |
15 | 16 | ||
16 | newtype JobId = JobId Integer | 17 | newtype JobId = JobId Integer |
17 | deriving (Show, Eq, Ord, Enum, FromText, ToText, FromJSON, ToJSON) | 18 | deriving (Show, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) |
18 | 19 | ||
19 | newtype DraftId = DraftId Integer | 20 | newtype DraftId = DraftId Integer |
20 | deriving (Show, Eq, Ord, Enum, FromText, ToText, FromJSON, ToJSON) | 21 | deriving (Show, Eq, Ord, Num, Real, Integral, Enum, FromText, ToText, FromJSON, ToJSON) |
22 | |||
23 | castId :: (Integral a, Enum b) => a -> b | ||
24 | castId = toEnum . fromInteger . toInteger | ||