diff --git a/Example.hs b/Example.hs
new file mode 100644
--- /dev/null
+++ b/Example.hs
@@ -0,0 +1,42 @@
+-- |
+--
+-- Demonstrates the basic usage of the PlplotCanvas to embed a plot in a Gnome application. 
+--
+module Main where
+
+import Graphics.UI.Gtk
+import Graphics.UI.Gtk.Glade
+
+import Graphics.PLplot
+
+main :: IO ()
+main = do
+  initGUI
+  Just xml <- xmlNew "example.glade"
+  window1 <- xmlGetWidget xml castToWindow "window1"
+  -- button <- xmlGetWidget xml castToButton "button1"
+  onDestroy window1 mainQuit  -- ???
+  canvas <- plplotCanvasNew
+  plplotCanvasSetSize canvas 1000 600
+  containerAdd window1 canvas
+  widgetShowAll window1
+  runPLplot canvas example
+  mainGUI
+
+example :: PLplot p => PLplotM p ()
+-- example :: PLplotM' ()
+example = do
+  adv 0 -- Advance to first page
+  col0 15 -- Set color to black
+  wid 2 -- Set the pen width
+  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
+
+  -- Draw the line
+  col0 1 -- Set the pen color
+  line $ zip [0,1,2,3,4,5,6,7,8,9,10] [0,0.1,0.4,0.9,1.6,2.6,3.6,4.9,6.4,8.1,10]
+
+  -- Advancing the page finalizes this plot
+  adv 0
diff --git a/Graphics/PLplot.chs b/Graphics/PLplot.chs
new file mode 100644
--- /dev/null
+++ b/Graphics/PLplot.chs
@@ -0,0 +1,160 @@
+-- -*- haskell -*-
+-- {-# LANGUAGE: ForeignFunctionInterface #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.PLplot
+-- License     :  BSD-style
+-- 
+-- Maintainer  :  Yakov Z <iakovz@gmail.com>
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- PlplotCanvas Widget for Gnome/GTK
+--
+-- Plots can be embedded into Gnome/GTK applications by using the PlplotCanvas widget.
+--
+-----------------------------------------------------------------------------
+module Graphics.PLplot (
+  -- * PlplotCanvas Widget
+    PlplotCanvas
+  , plplotCanvasNew
+  , plplotCanvasSetSize
+
+  -- * PLplot API
+  , PLplot(..)
+  -- , adv
+  -- , col0
+  -- , wid
+  -- , vsta
+  -- , wind
+  -- , box
+  -- , lab
+  -- , line
+
+  , PLplotM
+  , runPLplot
+  ) where
+
+-- import Control.Monad	(liftM)
+-- import Control.Monad.Trans
+import System.Glib.FFI
+import System.Glib.UTFString
+import System.Glib.Attributes
+import System.Glib.Properties
+import Graphics.UI.Gtk.Abstract.Object	(makeNewObject)
+import Graphics.UI.Gtk.Types
+-- XXX Graphics/UI/GTK/Types.csh needs
+import System.Glib.GType	(GType, typeInstanceIsA)
+
+#include <plplotcanvas.h>
+-- context lib="gtk" prefix="plplot" ???
+
+-- The usage of foreignPtrToPtr should be safe as the evaluation will only be
+-- forced if the object is used afterwards
+--
+castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String
+                                                -> (obj -> obj')
+castTo gtype objTypeName obj =
+  case toGObject obj of
+    gobj@(GObject objFPtr)
+      | typeInstanceIsA ((unsafeForeignPtrToPtr.castForeignPtr) objFPtr) gtype
+                  -> unsafeCastGObject gobj
+      | otherwise -> error $ "Cannot cast object to " ++ objTypeName
+
+-- Graphics/UI/GTK/Types.chs
+{#pointer *PlplotCanvas foreign newtype #}
+
+mkPlplotCanvas = PlplotCanvas
+unPlplotCanvas (PlplotCanvas o) = o
+
+-- XXX PlplotCanvas is a subclass of the GnomeCanvas
+class LayoutClass o => PlplotCanvasClass o
+toPlplotCanvas :: PlplotCanvasClass o => o -> PlplotCanvas
+toPlplotCanvas = unsafeCastGObject . toGObject
+
+instance PlplotCanvasClass PlplotCanvas
+instance LayoutClass PlplotCanvas
+instance ContainerClass PlplotCanvas
+instance WidgetClass PlplotCanvas
+instance ObjectClass PlplotCanvas
+instance GObjectClass PlplotCanvas where
+  toGObject = mkGObject . castForeignPtr . unPlplotCanvas
+  unsafeCastGObject = mkPlplotCanvas . castForeignPtr . unGObject
+
+castToPlplotCanvas :: GObjectClass obj => obj -> PlplotCanvas
+castToPlplotCanvas = castTo gTypePlplotCanvas "PlplotCanvas"
+
+gTypePlplotCanvas :: GType
+gTypePlplotCanvas =
+  {# call fun unsafe plplot_canvas_get_type #}
+
+-- Graphics/UI/GTK/Layout/PlplotCanvas.chs.pp
+
+--------------------
+-- Constructors
+
+-- | Creates a new 'PlplotCanvas' widget.
+--
+plplotCanvasNew :: IO PlplotCanvas
+plplotCanvasNew =
+  makeNewObject mkPlplotCanvas $
+  {# call unsafe plplot_canvas_new #}
+
+--------------------
+-- Methods
+
+-- | Sets 'PlplotCanvas' widget width and height.
+--
+plplotCanvasSetSize :: PlplotCanvas
+ -> Int
+ -> Int
+ -> IO ()
+plplotCanvasSetSize (PlplotCanvas o) width height =
+  {# call plplot_canvas_set_size #}
+    (unsafeForeignPtrToPtr o)
+    (fromIntegral width)
+    (fromIntegral height)
+
+class Monad (PLplotM p) => PLplot p where
+    adv :: Int -> PLplotM p () -- p -> IO ()
+    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 ()
+    lab :: String -> String -> String -> PLplotM p ()
+    line :: [(Double, Double)] -> PLplotM p ()   -- XXX
+
+instance PLplot PlplotCanvas where
+    adv page = MkP (\(PlplotCanvas o) -> {# call plplot_canvas_adv #} (unsafeForeignPtrToPtr o) (fromIntegral page))
+--    adv page = liftIO $ {# call plplot_canvas_adv #} (unsafeForeignPtrToPtr o) (fromIntegral page)
+    col0 icol0 = MkP (\(PlplotCanvas o) -> {# call plplot_canvas_col0 #} (unsafeForeignPtrToPtr o) (fromIntegral icol0))
+    wid width = MkP $ \(PlplotCanvas o) -> {# call plplot_canvas_wid #} (unsafeForeignPtrToPtr o) (fromIntegral width)
+    vsta = MkP $ \(PlplotCanvas o) -> {# call plplot_canvas_vsta #} (unsafeForeignPtrToPtr o)
+    wind xmin xmax ymin ymax = MkP $ \(PlplotCanvas o) -> {# call plplot_canvas_wind #} (unsafeForeignPtrToPtr o) (fromRational (toRational xmin)) (fromRational (toRational xmax)) (fromRational (toRational ymin)) (fromRational (toRational ymax))
+    box xopt xtick nxsub yopt ytick nysub = MkP $ \(PlplotCanvas o) -> withCString xopt $ \xo -> withCString yopt $ \yo -> {# call plplot_canvas_box #} (unsafeForeignPtrToPtr o) xo (fromRational (toRational xtick)) (fromIntegral nxsub) yo (fromRational (toRational ytick)) (fromIntegral nysub)
+    lab xlabel ylabel zlabel = MkP $ \(PlplotCanvas o) -> withCString xlabel $ \xl -> withCString ylabel $ \yl -> withCString zlabel $ \zl -> {# call plplot_canvas_lab #} (unsafeForeignPtrToPtr o) xl yl zl
+    line ps = MkP $ \(PlplotCanvas o) -> withArray xs $ \x -> withArray ys $ \y -> {# call plplot_canvas_line #} (unsafeForeignPtrToPtr o) (fromIntegral (length ps)) x y
+                               where (xs', ys') = unzip ps
+                                     xs = map (fromRational . toRational) xs'
+                                     ys = map (fromRational . toRational) ys'
+
+data PLplotM p a = MkP (p -> IO a)
+
+instance Monad (PLplotM PlplotCanvas) where    
+    return x = MkP $ \p -> return x
+    (MkP f) >>= act = MkP $ \p -> do
+                      a <- f p
+                      let MkP g = act a
+                      b <- g p
+                      return b
+
+-- instance MonadIO (PLplotM PlplotCanvas) where
+--     liftIO act = MkP $ \_ -> do { a <- act ; return a }
+
+runPLplot :: p -> (PLplotM p a) -> IO a
+runPLplot p (MkP f) = do
+  a <- f p
+  return a
+
+-- newtype PLplotM' a = PLplotM PlplotCanvas a
diff --git a/HPlot.cabal b/HPlot.cabal
new file mode 100644
--- /dev/null
+++ b/HPlot.cabal
@@ -0,0 +1,41 @@
+Name:		HPlot
+Version:	0.1
+Cabal-Version:  >= 1.2
+License:	BSD3
+License-File: license
+Author:		Yakov Z <iakovz@gmail.com>
+Maintainer:     Yakov Z <iakovz@gmail.com>
+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. 
+  .
+  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
+extra-source-files: example.glade, license
+
+Library
+  Build-Depends:	base, 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
+
+Executable           Example
+  build-depends:     base, 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
diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,6 @@
+#! /usr/bin/env runhaskell
+
+> import Distribution.Simple
+> main = defaultMain
+> -- import Distribution.Simple
+> -- main = defaultMainWithHooks autoconfUserHooks
diff --git a/example.glade b/example.glade
new file mode 100644
--- /dev/null
+++ b/example.glade
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.5 on Sun May 17 12:11:01 2009 -->
+<glade-interface>
+  <widget class="GtkWindow" id="window1">
+    <property name="width_request">1200</property>
+    <property name="height_request">700</property>
+    <child>
+      <placeholder/>
+    </child>
+  </widget>
+</glade-interface>
diff --git a/license b/license
new file mode 100644
--- /dev/null
+++ b/license
@@ -0,0 +1,24 @@
+Copyright (c) 2009 Yakov Zaytsev
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The names of the authors may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
