diff options
Diffstat (limited to 'spec/src')
| -rw-r--r-- | spec/src/Thermoprint/Printout.hs | 10 | 
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) | |||
| 23 | import Data.ByteString.Lazy (ByteString) | 23 | import Data.ByteString.Lazy (ByteString) | 
| 24 | import qualified Data.ByteString.Lazy as LBS (toStrict) | 24 | import qualified Data.ByteString.Lazy as LBS (toStrict) | 
| 25 | 25 | ||
| 26 | import qualified Data.ByteString as Strict (ByteString) | ||
| 27 | |||
| 26 | import GHC.Generics (Generic) | 28 | import GHC.Generics (Generic) | 
| 27 | import Control.DeepSeq (NFData) | 29 | import Control.DeepSeq (NFData) | 
| 28 | import Data.Aeson (FromJSON(..), ToJSON(..), Value(..)) | 30 | import Data.Aeson (FromJSON(..), ToJSON(..), Value(..)) | 
| 29 | import qualified Data.Aeson as JSON (encode, decode, eitherDecodeStrict') | 31 | import qualified Data.Aeson as JSON (encode, decode, eitherDecodeStrict') | 
| 30 | import Data.Aeson.Types (typeMismatch) | 32 | import Data.Aeson.Types (typeMismatch) | 
| 31 | 33 | ||
| 34 | import Data.Proxy (Proxy(..)) | ||
| 35 | |||
| 32 | import Database.Persist.Class (PersistField(..)) | 36 | import Database.Persist.Class (PersistField(..)) | 
| 37 | import Database.Persist.Sql (PersistFieldSql(..)) | ||
| 33 | 38 | ||
| 34 | import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) | 39 | import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) | 
| 35 | import Test.QuickCheck.Modifiers (NonNegative(..)) | 40 | import Test.QuickCheck.Modifiers (NonNegative(..)) | 
| @@ -67,7 +72,10 @@ type Printout = Seq Paragraph | |||
| 67 | 72 | ||
| 68 | instance PersistField Printout where | 73 | instance 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 | |||
| 77 | instance 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 | 
| 73 | type Paragraph = Seq Chunk | 81 | type Paragraph = Seq Chunk | 
