@@ -37,6 +37,8 @@ import Codec.Binary.UTF8.Width
3737
3838import Codec.Binary.UTF8.String ( decode )
3939
40+import Control.DeepSeq
41+
4042import qualified Data.ByteString as BS
4143import Data.Monoid
4244import qualified Data.Sequence as Seq
@@ -69,7 +71,7 @@ type DisplayString = Seq.Seq (Char, Word)
6971--
7072-- todo: increase the number of encoded bytestring formats supported.
7173data Image =
72− -- A horizontal text span is always >= 1 column and has a row height of 1.
74+ -- | A horizontal text span is always >= 1 column and has a row height of 1.
7375 HorizText
7476 { attr :: !Attr
7577 -- All character data is stored as Char sequences with the ISO-10646 encoding.
@@ -77,7 +79,7 @@ data Image =
7779 , output_width :: !Word -- >= 0
7880 , char_width :: !Word -- >= 1
7981 }
80− -- A horizontal join can be constructed between any two images. However a HorizJoin instance is
82+ -- | A horizontal join can be constructed between any two images. However a HorizJoin instance is
8183 -- required to be between two images of equal height. The horiz_join constructor adds background
8284 -- filles to the provided images that assure this is true for the HorizJoin value produced.
8385 | HorizJoin
@@ -86,7 +88,7 @@ data Image =
8688 , output_width :: !Word -- >= 1
8789 , output_height :: !Word -- >= 1
8890 }
89− -- A veritical join can be constructed between any two images. However a VertJoin instance is
91+ -- | A veritical join can be constructed between any two images. However a VertJoin instance is
9092 -- required to be between two images of equal width. The vert_join constructor adds background
9193 -- fills to the provides images that assure this is true for the VertJoin value produced.
9294 | VertJoin
@@ -95,13 +97,13 @@ data Image =
9597 , output_width :: !Word -- >= 1
9698 , output_height :: !Word -- >= 1
9799 }
98− -- A background fill will be filled with the background pattern. The background pattern is
100+ -- | A background fill will be filled with the background pattern. The background pattern is
99101 -- defined as a property of the Picture this Image is used to form.
100102 | BGFill
101103 { output_width :: !Word -- >= 1
102104 , output_height :: !Word -- >= 1
103105 }
104− -- The combining operators identity constant.
106+ -- | The combining operators identity constant.
105107 -- EmptyImage <|> a = a
106108 -- EmptyImage <-> a = a
107109 --
@@ -135,7 +137,17 @@ instance Show Image where
135137instance Monoid Image where
136138 mempty = empty_image
137139 mappend = (<->)
138−
140+
141+instance NFData Image where
142+ rnf EmptyImage = ()
143+ rnf (Translation s i) = s `deepseq` i `deepseq` ()
144+ rnf (ImagePad s i) = s `deepseq` i `deepseq` ()
145+ rnf (ImageCrop s i) = s `deepseq` i `deepseq` ()
146+ rnf (BGFill !w !h) = ()
147+ rnf (VertJoin t b !w !h) = t `deepseq` b `deepseq` ()
148+ rnf (HorizJoin l r !w !h) = l `deepseq` r `deepseq` ()
149+ rnf (HorizText !a s !w !cw) = s `deepseq` ()
150+
139151-- A horizontal text image of 0 characters in width simplifies to the EmptyImage
140152horiz_text :: Attr -> DisplayString -> Word -> Image
141153horiz_text a txt ow