ihaskell-plot (empty) → 0.2.0.0
raw patch · 4 files changed
+139/−0 lines, 4 filesdep +basedep +bytestringdep +classy-preludesetup-changed
Dependencies added: base, bytestring, classy-prelude, ihaskell, plot
Files
- IHaskell/Display/Plot.hs +46/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- ihaskell-plot.cabal +71/−0
+ IHaskell/Display/Plot.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE NoImplicitPrelude #-}++module IHaskell.Display.Plot where++import ClassyPrelude++import qualified Data.ByteString.Char8 as Char++import Graphics.Rendering.Plot++import IHaskell.Display++instance IHaskellDisplay (Figure a) where+ display fig = do+ let figure = fig >> return ()+ pngDisp <- figureData figure PNG+ svgDisp <- figureData figure SVG+ return $ Display [pngDisp, svgDisp]++figureData :: Figure () -> OutputType -> IO DisplayData+figureData figure format = do+ switchToTmpDir++ -- Width and height+ let size = 300+ w = size+ h = size++ -- Write the image.+ let fname = ".ihaskell-plot." ++ extension format+ writeFigure format fname (w, h) figure++ -- Read back, and convert to base64.+ imgData <- readFile fname+ let value =+ 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 _ = ""
+ LICENSE view
@@ -0,0 +1,20 @@+The MIT License (MIT)++Copyright (c) 2013 Andrew Gibiansky++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of+the Software, and to permit persons to whom the Software is furnished to do so,+subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ ihaskell-plot.cabal view
@@ -0,0 +1,71 @@+-- The name of the package.+name: ihaskell-plot++-- The package version. See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary: +-+------- breaking API changes+-- | | +----- non-breaking API additions+-- | | | +--- code changes with no API change+version: 0.2.0.0++-- A short (one-line) description of the package.+synopsis: IHaskell display instance for Plot (from plot package)++-- A longer description of the package.+-- description: ++-- URL for the project homepage or repository.+homepage: http://www.github.com/gibiansky/ihaskell++-- The license under which the package is released.+license: MIT++-- The file containing the license text.+license-file: LICENSE++-- The package author(s).+author: Sumit Sahrawat <sumit.sahrawat.apm13@itbhu.ac.in>++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer: Sumit Sahrawat <sumit.sahrawat.apm13@itbhu.ac.in>,+ Andrew Gibiansky <andrew.gibiansky@gmail.com>++-- A copyright notice.+-- copyright: ++category: Development++build-type: Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+-- extra-source-files: ++-- Constraint on the version of Cabal needed to build this package.+cabal-version: >=1.16++library+ -- Modules exported by the library.+ exposed-modules: IHaskell.Display.Plot+ + -- Modules included in this library but not exported.+ -- other-modules: + + -- Language extensions.+ default-extensions: DoAndIfThenElse+ OverloadedStrings+ + -- Other library packages from which modules are imported.+ build-depends: base >=4.6 && <4.9,+ classy-prelude >= 0.10.5,+ plot,+ bytestring,+ ihaskell >= 0.6.2+ + -- Directories containing source files.+ -- hs-source-dirs: + + -- Base language which the package is written in.+ default-language: Haskell2010