Skip to content

Commit 76487ff

Browse files
authored
Merge pull request #5 from fhaust/master
added DeepSeq instances
2 parents e07f01d + 8780174 commit 76487ff

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

matplotlib.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ library
2525
exposed-modules: Graphics.Matplotlib.Internal
2626
, Graphics.Matplotlib
2727
build-depends: base >= 4.7 && < 5
28+
, deepseq
2829
, process
2930
, bytestring
3031
, aeson

src/Graphics/Matplotlib.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ zlabel label = mp # "ax.set_zlabel(" # raw label ## ")"
444444

445445
setSizeInches w h = mp # "fig.set_size_inches(" # w # "," # h # ", forward=True)"
446446

447-
tightLayout = mp # "fig.tight_layout()"
447+
tightLayout = mp # "fig.tight_layout(" ## ")"
448448

449449
xkcd = mp # "plot.xkcd()"
450450

src/Graphics/Matplotlib/Internal.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import System.IO.Temp
88
import System.Process
99
import Data.Aeson
1010
import Control.Monad
11+
import Control.DeepSeq
1112
import System.IO
1213
import qualified Data.ByteString.Lazy as B
1314
import Data.List
@@ -36,6 +37,9 @@ instance Monoid Matplotlib where
3637
mempty = mp
3738
mappend = (%)
3839

40+
instance NFData Matplotlib where
41+
rnf (Matplotlib cs po re) = rnf cs `seq` rnf po `seq` rnf re
42+
3943
-- | A maplotlib command, right now we have a very shallow embedding essentially
4044
-- dealing in strings containing python code as well as the ability to load
4145
-- data. The loaded data should be a json object.
@@ -44,6 +48,11 @@ data MplotCommand =
4448
| forall x. MplotImage x => LoadImage x
4549
| Exec { es :: String }
4650

51+
instance NFData MplotCommand where
52+
rnf (LoadData b) = rnf b
53+
rnf (Exec es) = rnf es
54+
-- don't care too much about the LoadImage
55+
4756
-- | Throughout the API we need to accept options in order to expose
4857
-- matplotlib's many configuration options.
4958
data Option =

0 commit comments

Comments
 (0)