From 32fd365fb546e7e2ad195b575be4bca457cba6e9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 23 Jan 2016 12:58:14 +0000 Subject: cleanup of persistent-instances --- .../src/Thermoprint/Server/Database/Instances.hs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'server/src') 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 import Thermoprint.API (Printout, JobStatus, PrintingError) -import Database.Persist (PersistField(..)) -import Database.Persist.Sql (PersistFieldSql(..)) import Database.Persist.TH -import Control.Monad ((<=<)) -import Data.Bifunctor - -import qualified Data.Aeson as JSON (encode, eitherDecodeStrict') - -import Data.ByteString (ByteString) -import qualified Data.ByteString.Lazy as LBS (toStrict) -import qualified Data.Text as T (pack) - -import Data.Proxy - --- | Instead of deriving an instance using 'derivePersistField', which would use 'show' and 'read', we write our own by hand in order to use json -instance PersistField Printout where - toPersistValue = toPersistValue . LBS.toStrict . JSON.encode - fromPersistValue = first T.pack . JSON.eitherDecodeStrict' <=< fromPersistValue - -instance PersistFieldSql Printout where - sqlType _ = sqlType (Proxy :: Proxy ByteString) - +derivePersistFieldJSON "Printout" derivePersistField "PrintingError" derivePersistField "JobStatus" -- cgit v1.2.3