diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-23 12:58:14 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-23 12:58:14 +0000 |
commit | 32fd365fb546e7e2ad195b575be4bca457cba6e9 (patch) | |
tree | eb38f4b95654f43907dc3077bb550452d0f8ecb1 /server | |
parent | b508a6bd35d28260f307acf8ffde8b7acf843a09 (diff) | |
download | thermoprint-32fd365fb546e7e2ad195b575be4bca457cba6e9.tar thermoprint-32fd365fb546e7e2ad195b575be4bca457cba6e9.tar.gz thermoprint-32fd365fb546e7e2ad195b575be4bca457cba6e9.tar.bz2 thermoprint-32fd365fb546e7e2ad195b575be4bca457cba6e9.tar.xz thermoprint-32fd365fb546e7e2ad195b575be4bca457cba6e9.zip |
cleanup of persistent-instances
Diffstat (limited to 'server')
-rw-r--r-- | server/src/Thermoprint/Server/Database/Instances.hs | 22 | ||||
-rw-r--r-- | server/thermoprint-server.cabal | 2 | ||||
-rw-r--r-- | server/thermoprint-server.nix | 14 |
3 files changed, 8 insertions, 30 deletions
diff --git a/server/src/Thermoprint/Server/Database/Instances.hs b/server/src/Thermoprint/Server/Database/Instances.hs index f5c22fd..e54f90e 100644 --- a/server/src/Thermoprint/Server/Database/Instances.hs +++ b/server/src/Thermoprint/Server/Database/Instances.hs | |||
@@ -6,28 +6,8 @@ module Thermoprint.Server.Database.Instances where | |||
6 | 6 | ||
7 | import Thermoprint.API (Printout, JobStatus, PrintingError) | 7 | import Thermoprint.API (Printout, JobStatus, PrintingError) |
8 | 8 | ||
9 | import Database.Persist (PersistField(..)) | ||
10 | import Database.Persist.Sql (PersistFieldSql(..)) | ||
11 | import Database.Persist.TH | 9 | import Database.Persist.TH |
12 | 10 | ||
13 | import Control.Monad ((<=<)) | 11 | derivePersistFieldJSON "Printout" |
14 | import Data.Bifunctor | ||
15 | |||
16 | import qualified Data.Aeson as JSON (encode, eitherDecodeStrict') | ||
17 | |||
18 | import Data.ByteString (ByteString) | ||
19 | import qualified Data.ByteString.Lazy as LBS (toStrict) | ||
20 | import qualified Data.Text as T (pack) | ||
21 | |||
22 | import Data.Proxy | ||
23 | |||
24 | -- | Instead of deriving an instance using 'derivePersistField', which would use 'show' and 'read', we write our own by hand in order to use json | ||
25 | instance PersistField Printout where | ||
26 | toPersistValue = toPersistValue . LBS.toStrict . JSON.encode | ||
27 | fromPersistValue = first T.pack . JSON.eitherDecodeStrict' <=< fromPersistValue | ||
28 | |||
29 | instance PersistFieldSql Printout where | ||
30 | sqlType _ = sqlType (Proxy :: Proxy ByteString) | ||
31 | |||
32 | derivePersistField "PrintingError" | 12 | derivePersistField "PrintingError" |
33 | derivePersistField "JobStatus" | 13 | derivePersistField "JobStatus" |
diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index bd22482..8862255 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal | |||
@@ -40,8 +40,6 @@ library | |||
40 | , either >=4.4.1 && <5 | 40 | , either >=4.4.1 && <5 |
41 | , text >=1.2.1 && <2 | 41 | , text >=1.2.1 && <2 |
42 | , stm >=2.4.4 && <3 | 42 | , stm >=2.4.4 && <3 |
43 | , aeson >=0.9.0 && <1 | ||
44 | , bytestring >=0.10.6 && <1 | ||
45 | hs-source-dirs: src | 43 | hs-source-dirs: src |
46 | default-language: Haskell2010 | 44 | default-language: Haskell2010 |
47 | 45 | ||
diff --git a/server/thermoprint-server.nix b/server/thermoprint-server.nix index 0f85c9d..57e94a3 100644 --- a/server/thermoprint-server.nix +++ b/server/thermoprint-server.nix | |||
@@ -1,7 +1,7 @@ | |||
1 | { mkDerivation, aeson, base, bytestring, containers | 1 | { mkDerivation, base, containers, data-default-class, dyre, either |
2 | , data-default-class, dyre, either, monad-logger, mtl, persistent | 2 | , monad-logger, mtl, persistent, persistent-sqlite |
3 | , persistent-sqlite, persistent-template, resourcet, servant-server | 3 | , persistent-template, resourcet, servant-server, stdenv, stm, text |
4 | , stdenv, stm, text, thermoprint-spec, transformers, wai, warp | 4 | , thermoprint-spec, transformers, wai, warp |
5 | }: | 5 | }: |
6 | mkDerivation { | 6 | mkDerivation { |
7 | pname = "thermoprint-server"; | 7 | pname = "thermoprint-server"; |
@@ -10,9 +10,9 @@ mkDerivation { | |||
10 | isLibrary = true; | 10 | isLibrary = true; |
11 | isExecutable = true; | 11 | isExecutable = true; |
12 | libraryHaskellDepends = [ | 12 | libraryHaskellDepends = [ |
13 | aeson base bytestring containers data-default-class dyre either | 13 | base containers data-default-class dyre either monad-logger mtl |
14 | monad-logger mtl persistent persistent-template resourcet | 14 | persistent persistent-template resourcet servant-server stm text |
15 | servant-server stm text thermoprint-spec transformers wai warp | 15 | thermoprint-spec transformers wai warp |
16 | ]; | 16 | ]; |
17 | executableHaskellDepends = [ | 17 | executableHaskellDepends = [ |
18 | base monad-logger mtl persistent-sqlite resourcet | 18 | base monad-logger mtl persistent-sqlite resourcet |