packages feed

HPlot 0.1 → 0.2

raw patch · 4 files changed

+88/−42 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

Example.hs view
@@ -32,7 +32,8 @@   vsta -- Set the viewport   wind 0.0 10.0 0.0 10.0 -- Set the window   box "bcnst" 0.0 0 "bcnstv" 0.0 0 -- Set the box-  lab "x-axis" "y-axis" "A Simple Plot" -- Draw some labels+  -- bin [] [BinNoExpand]+  lab "#<0x10>Мир" "y-axis" "A Simple Plot" -- Draw some labels    -- Draw the line   col0 1 -- Set the pen color
Graphics/PLplot.chs view
@@ -1,17 +1,17 @@ -- -*- haskell -*---- {-# LANGUAGE: ForeignFunctionInterface #-} ----------------------------------------------------------------------------- -- | -- Module      :  Graphics.PLplot -- License     :  BSD-style--- --- Maintainer  :  Yakov Z <iakovz@gmail.com>+--+-- Maintainer  :  Yakov ZAYTSEV <yakov@yakov.cc> -- Stability   :  experimental -- Portability :  portable -- -- PlplotCanvas Widget for Gnome/GTK ----- Plots can be embedded into Gnome/GTK applications by using the PlplotCanvas widget.+-- Plots can be embedded into Gnome/GTK applications+-- by using the PlplotCanvas widget. -- ----------------------------------------------------------------------------- module Graphics.PLplot (@@ -22,21 +22,16 @@    -- * PLplot API   , PLplot(..)-  -- , adv-  -- , col0-  -- , wid-  -- , vsta-  -- , wind-  -- , box-  -- , lab-  -- , line    , PLplotM   , runPLplot++  , BinOpt(..)   ) where  -- import Control.Monad	(liftM) -- import Control.Monad.Trans+import Data.Bits ((.|.)) import System.Glib.FFI import System.Glib.UTFString import System.Glib.Attributes@@ -115,15 +110,36 @@     (fromIntegral width)     (fromIntegral height) +#if defined(PL_DOUBLE) || defined(DOUBLE)+-- | Flt mirrors PLFLT+type Flt = Double+-- type Flt = {#type PLFLT#} -- maps to CDouble+#else+type Flt = Float+#endif++#c+enum BinOpt {+  BinDefault = PL_BIN_DEFAULT,+  BinCentred = PL_BIN_CENTRED,+  BinNoExpand = PL_BIN_NOEXPAND,+  BinNoEmpty = PL_BIN_NOEMPTY+};+#endc++{#enum BinOpt {}#}+ class Monad (PLplotM p) => PLplot p where-    adv :: Int -> PLplotM p () -- p -> IO ()+    adv :: Int -> PLplotM p ()     col0 :: Int -> PLplotM p ()     wid :: Int -> PLplotM p ()     vsta :: PLplotM p ()-    wind :: Float -> Float -> Float -> Float -> PLplotM p ()-    box :: String -> Float -> Int -> String -> Float -> Int -> PLplotM p ()+    wind :: Flt -> Flt -> Flt -> Flt -> PLplotM p ()+    box :: String -> Flt -> Int -> String -> Flt -> Int -> PLplotM p ()     lab :: String -> String -> String -> PLplotM p ()-    line :: [(Double, Double)] -> PLplotM p ()   -- XXX+    line :: [(Flt, Flt)] -> PLplotM p ()+    bin :: [(Flt, Flt)] -> [BinOpt] -> PLplotM p ()+    ssub :: Int -> Int -> PLplotM p ()  instance PLplot PlplotCanvas where     adv page = MkP (\(PlplotCanvas o) -> {# call plplot_canvas_adv #} (unsafeForeignPtrToPtr o) (fromIntegral page))@@ -138,10 +154,25 @@                                where (xs', ys') = unzip ps                                      xs = map (fromRational . toRational) xs'                                      ys = map (fromRational . toRational) ys'+    ssub = gtk_ssub+    bin = gtk_bin +gtk_ssub :: Int -> Int -> PLplotM PlplotCanvas ()+gtk_ssub nx ny = MkP (\(PlplotCanvas o) -> {# call plplot_canvas_ssub #} (unsafeForeignPtrToPtr o)+						(fromIntegral nx) (fromIntegral ny))++gtk_bin :: [(Flt, Flt)] -> [BinOpt] -> PLplotM PlplotCanvas ()+gtk_bin ps bops = MkP $ \(PlplotCanvas o) -> withArray xs $ \x -> withArray ys $ \y -> {# call plplot_canvas_bin #} (unsafeForeignPtrToPtr o) (fromIntegral (length ps)) x y (fromIntegral bops')+                               where+                                   (xs', ys') = unzip ps+                                   xs = map (fromRational . toRational) xs'+                                   ys = map (fromRational . toRational) ys'+                                   bops' = foldl (.|.) (fromEnum BinDefault)+                                         $ map fromEnum bops+ data PLplotM p a = MkP (p -> IO a) -instance Monad (PLplotM PlplotCanvas) where    +instance Monad (PLplotM PlplotCanvas) where     return x = MkP $ \p -> return x     (MkP f) >>= act = MkP $ \p -> do                       a <- f p
HPlot.cabal view
@@ -1,41 +1,55 @@ Name:		HPlot-Version:	0.1-Cabal-Version:  >= 1.2+Version:	0.2+-- Cabal-Version:  >= 1.2 License:	BSD3-License-File: license-Author:		Yakov Z <iakovz@gmail.com>-Maintainer:     Yakov Z <iakovz@gmail.com>+License-file:   license+Author:		Yakov ZAYTSEV <yakov@yakov.cc>+Maintainer:     Yakov ZAYTSEV <yakov@yakov.cc>+Homepage:       http://yakov.cc/HPlot.html Category:	Graphics, Foreign Synopsis:	A minimal monadic PLplot interface for Haskell Description:   This package provides simple monadic interface to the PLplot cross-platform software    package for creating scientific plots.    .+  Haddock documentation (hyperlinked with source code) is available from homepage+  .   PlplotCanvas widget is implemented to be compatible with gtk2hs. PLplot type class allows   addition of other display drivers without need to adopt application code   .   The idea was that with the help of PLplotM monad it should be easy to make    more abstract interfaces and combinators to do plots   .-build-type: Simple+  You are welcome to send your changes to be included in future release+  .+  It will be great if you will do 'git format-patch' to prepare email with changes against particular version+  .+  Changes since 0.1:+  .+  * Roman Salmin contributed 'ssub' and 'bin' functions+  .+  * 'Flt' type has been added which mirrors PLFLT+  .+build-type:     Simple extra-source-files: example.glade, license--Library-  Build-Depends:	base, gtk, glade, glib-  Exposed-modules:-    Graphics.PLplot+Build-Depends:	base >= 4.0 && < 4.2+Build-Depends:  gtk, glade, glib+Exposed-modules:+                Graphics.PLplot --  ghc-options: -Wall -fglasgow-exts-  ghc-options: -Wall -  extensions: ForeignFunctionInterface, FlexibleContexts, FlexibleInstances-  build-tools: c2hs-  pkgconfig-depends: plplotd-gnome2+ghc-options:    -Wall +extensions:     ForeignFunctionInterface, FlexibleContexts, FlexibleInstances+build-tools:    c2hs+pkgconfig-depends: plplotd-gnome2 -Executable           Example-  build-depends:     base, gtk, glade, glib-  Main-Is:           Example.hs-  hs-source-dirs:    .-  Other-Modules:     Graphics.PLplot+Executable:     Example+Build-Depends:  base >= 4.0 && < 4.2+Build-Depends:  gtk, glade, glib+Main-Is:        Example.hs+hs-source-dirs: .+Other-Modules:+                Graphics.PLplot --  ghc-options: -Wall -fglasgow-exts-  ghc-options: -Wall-  extensions: ForeignFunctionInterface, FlexibleContexts, FlexibleInstances-  pkgconfig-depends: plplotd-gnome2+ghc-options:    -Wall+extensions:     ForeignFunctionInterface, FlexibleContexts, FlexibleInstances+pkgconfig-depends: plplotd-gnome2
license view
@@ -1,4 +1,4 @@-Copyright (c) 2009 Yakov Zaytsev+Copyright (c) 2009 Yakov Zaytsev, Roman Salmin All rights reserved.  Redistribution and use in source and binary forms, with or without