aboutsummaryrefslogtreecommitdiff
path: root/spec/src/Thermoprint/Printout.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-20 13:02:02 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-20 13:02:02 +0000
commit64e3df81b31cc79b035913bda4d093e31bb1955a (patch)
tree8aad2a9ab446daaff4be91af4838e71698ab3be6 /spec/src/Thermoprint/Printout.hs
parentd5beb20783df5f13357dd6d2a55c48c97da578f4 (diff)
downloadthermoprint-64e3df81b31cc79b035913bda4d093e31bb1955a.tar
thermoprint-64e3df81b31cc79b035913bda4d093e31bb1955a.tar.gz
thermoprint-64e3df81b31cc79b035913bda4d093e31bb1955a.tar.bz2
thermoprint-64e3df81b31cc79b035913bda4d093e31bb1955a.tar.xz
thermoprint-64e3df81b31cc79b035913bda4d093e31bb1955a.zip
Store Printouts in persistent sql-based dbs
Diffstat (limited to 'spec/src/Thermoprint/Printout.hs')
-rw-r--r--spec/src/Thermoprint/Printout.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs
index 397a1af..89be802 100644
--- a/spec/src/Thermoprint/Printout.hs
+++ b/spec/src/Thermoprint/Printout.hs
@@ -23,13 +23,18 @@ import Data.Text.Lazy (Text)
23import Data.ByteString.Lazy (ByteString) 23import Data.ByteString.Lazy (ByteString)
24import qualified Data.ByteString.Lazy as LBS (toStrict) 24import qualified Data.ByteString.Lazy as LBS (toStrict)
25 25
26import qualified Data.ByteString as Strict (ByteString)
27
26import GHC.Generics (Generic) 28import GHC.Generics (Generic)
27import Control.DeepSeq (NFData) 29import Control.DeepSeq (NFData)
28import Data.Aeson (FromJSON(..), ToJSON(..), Value(..)) 30import Data.Aeson (FromJSON(..), ToJSON(..), Value(..))
29import qualified Data.Aeson as JSON (encode, decode, eitherDecodeStrict') 31import qualified Data.Aeson as JSON (encode, decode, eitherDecodeStrict')
30import Data.Aeson.Types (typeMismatch) 32import Data.Aeson.Types (typeMismatch)
31 33
34import Data.Proxy (Proxy(..))
35
32import Database.Persist.Class (PersistField(..)) 36import Database.Persist.Class (PersistField(..))
37import Database.Persist.Sql (PersistFieldSql(..))
33 38
34import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) 39import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink)
35import Test.QuickCheck.Modifiers (NonNegative(..)) 40import Test.QuickCheck.Modifiers (NonNegative(..))
@@ -67,7 +72,10 @@ type Printout = Seq Paragraph
67 72
68instance PersistField Printout where 73instance PersistField Printout where
69 toPersistValue = toPersistValue . LBS.toStrict . JSON.encode 74 toPersistValue = toPersistValue . LBS.toStrict . JSON.encode
70 fromPersistValue = first T.pack . JSON.eitherDecodeStrict' <=< fromPersistValue 75 fromPersistValue = first T.pack . JSON.eitherDecodeStrict' <=< fromPersistValue
76
77instance PersistFieldSql Printout where
78 sqlType _ = sqlType (Proxy :: Proxy Strict.ByteString)
71 79
72-- | A 'Paragraph' is a non-seperated sequence of 'Chunk's 80-- | A 'Paragraph' is a non-seperated sequence of 'Chunk's
73type Paragraph = Seq Chunk 81type Paragraph = Seq Chunk