Skip to content

Commit 89a2186

Browse files
committed
added DeepSeq instances
1 parent e07f01d commit 89a2186

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
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/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)