Skip to content

Commit 3f5ebdf

Browse files
authored
Merge pull request #4 from fhaust/master
Matplotlib should be a Monoid
2 parents 17425a8 + fa1dc85 commit 3f5ebdf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Graphics/Matplotlib/Internal.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Control.Exception
1515
import qualified Data.Sequence as S
1616
import Data.Sequence (Seq, (|>), (><))
1717
import Data.Maybe
18+
import Data.Monoid
1819
import GHC.Exts(toList)
1920

2021
-- | A handy miscellaneous function to linearly map over a range of numbers in a given number of steps
@@ -30,6 +31,11 @@ data Matplotlib = Matplotlib {
3031
, mpRest :: Seq MplotCommand -- ^ Computations that follow the one that is pending
3132
}
3233

34+
-- | Monoid instance for Matplotlib type
35+
instance Monoid Matplotlib where
36+
mempty = mp
37+
mappend = (%)
38+
3339
-- | A maplotlib command, right now we have a very shallow embedding essentially
3440
-- dealing in strings containing python code as well as the ability to load
3541
-- data. The loaded data should be a json object.

0 commit comments

Comments
 (0)