blob: af5d4f8633f5f7be65ddde5ad8e2bff24068b14c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Job.Kind
( Kind(..)
) where
import Database.SQLite.Simple (SQLData(SQLText))
import Database.SQLite.Simple.FromField (fieldData, FromField(fromField))
import Database.SQLite.Simple.Ok (Ok(Ok, Errors))
import Database.SQLite.Simple.ToField (ToField(toField))
import qualified Data.Text as T
data Kind =
MonthlyPayment
| WeeklyReport
deriving (Eq, Show, Read)
instance FromField Kind where
fromField field = case fieldData field of
SQLText text -> Ok (read (T.unpack text) :: Kind)
_ -> Errors [error "SQLText field required for job kind"]
instance ToField Kind where
toField kind = SQLText . T.pack . show $ kind
|