packages feed

vacuum-ubigraph (empty) → 0.1

raw patch · 4 files changed

+117/−0 lines, 4 filesdep +basedep +containersdep +haxrsetup-changed

Dependencies added: base, containers, haxr, vacuum

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2009 Gleb Alexeyev++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. Neither the name of the author nor the names of his contributors+   may 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 OR CONTRIBUTORS 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ System/Vacuum/Ubigraph.hs view
@@ -0,0 +1,63 @@+module System.Vacuum.Ubigraph(view) where++import GHC.Vacuum+import Data.Char+import Text.Printf+import Data.List++import qualified Data.IntMap as IntMap+import qualified Data.IntSet as IntSet++import qualified Graphics.Ubigraph as U++nodeStyle n =+    case nodeName n of+      ":"  -> ("(:)", "cube", "#0000ff")++      k | k `elem` ["S#" ,"I#" ,"W#"+                   ,"I8#" ,"I16#" ,"I32#" ,"I64#"+                   ,"W8#" ,"W16#" ,"W32#" ,"W64#"] -> (showLit n, "sphere", "#00ff00")++      "C#" -> (show . chr . fromIntegral . head . nodeLits $ n, "sphere", "#00ff00")+      "D#" -> ("Double", "sphere", "#009900")+      "F#" -> ("Float", "sphere", "#009900")+++      "PS"    -> (printf "ByteString[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", "#ff0000")+      "Chunk" -> (printf "Chunk[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", "#ff0000")++      c   | z > 0 ->+                    (c ++ show (take (fromIntegral z) $ nodeLits n), "cube", "#990000")+          | otherwise -> (c, "cube", "#990000")+                    where z = itabLits (nodeInfo n)+        where+          showLit n = show (head $ nodeLits n)++-- | Render a value using Ubigraph+view :: a -> IO ()+view a = do+  U.clear srv+  mapM_ renderNode nodes+  mapM_ renderEdge edges+    where      +      g = vacuum a+      alist = toAdjList g+      nodes = nub $ map fst alist ++ concatMap snd alist+      edges = concatMap (\(n, ns) -> map ((,) n) ns) alist++      style nid = maybe ("...", "cube", "#ff0000") nodeStyle (IntMap.lookup nid g)++      renderNode nid = do+           U.newVertexWithId srv nid+           let (label, shape, color) = style nid+           U.setVertexAttribute srv nid "label" label+           U.setVertexAttribute srv nid "shape" shape+           U.setVertexAttribute srv nid "color" color+      +      renderEdge (a, b) = do+           e <- U.newEdge srv a b+           U.setEdgeAttribute srv e "stroke" "dotted"+           U.setEdgeAttribute srv e "arrow" "true"++      srv = U.defaultServer+
+ vacuum-ubigraph.cabal view
@@ -0,0 +1,22 @@+name:               vacuum-ubigraph+version:            0.1+cabal-version:      >= 1.2+build-type:         Simple+license:            BSD3+license-file:       LICENSE+category:           Development+author:             Gleb Alexeyev+maintainer:         Gleb Alexeyev <gleb.alexeev@gmail.com>+stability:          experimental+synopsis:           Visualize Haskell data structures using vacuum and Ubigraph+description:        Visualize Haskell data structures using vacuum and Ubigraph+                    To use it, you'll have to install Ubigraph first - see http://ubietylab.net/ubigraph/+                    Then run ubigraph server with default settings (with a command like $UBIGRAPH_DIR/bin/ubigraph_server)+                    Then load System.Vacuum.Ubigraph module into the ghci session and use `view' function, e.g.+                    > view [1..3]+library+  build-depends:    base >= 3,+                    vacuum,+                    haxr,+                    containers+  exposed-modules:  System.Vacuum.Ubigraph