mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-17 11:56:12 +00:00
Merge pull request #460 from sumitsahrawat/plot-patch
Generalize ihaskell-plot to work for all Figure types
This commit is contained in:
commit
6f194eb9ae
@ -1,5 +1,4 @@
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
|
||||
module IHaskell.Display.Plot where
|
||||
|
||||
@ -11,8 +10,9 @@ import Graphics.Rendering.Plot
|
||||
|
||||
import IHaskell.Display
|
||||
|
||||
instance IHaskellDisplay (Figure ()) where
|
||||
display figure = do
|
||||
instance IHaskellDisplay (Figure a) where
|
||||
display fig = do
|
||||
let figure = fig >> return ()
|
||||
pngDisp <- figureData figure PNG
|
||||
svgDisp <- figureData figure SVG
|
||||
return $ Display [pngDisp, svgDisp]
|
||||
@ -36,9 +36,11 @@ figureData figure format = do
|
||||
case format of
|
||||
PNG -> png w h $ base64 imgData
|
||||
SVG -> svg $ Char.unpack imgData
|
||||
_ -> error "Unsupported format for display"
|
||||
|
||||
return value
|
||||
|
||||
where
|
||||
extension SVG = "svg"
|
||||
extension PNG = "png"
|
||||
extension PNG = "png"
|
||||
extension _ = ""
|
Loading…
x
Reference in New Issue
Block a user