packages feed

visual-graphrewrite 0.3 → 0.3.1

raw patch · 3 files changed

+52/−173 lines, 3 files

Files

− GraphRewrite/Internal/Test.hs
@@ -1,145 +0,0 @@-module GraphRewrite.Internal.Test  where--import GraphRewrite.Internal.Rewrite-import GraphRewrite.Internal.RewriteTypes hiding (PointedGraph)--import System.IO.Unsafe---import Test.ChasingBottoms.TimeOut-import Test.LazySmallCheck-import qualified Data.IntMap as IM-import Data.List--{--Serial instance needed:-    Graph-    RewriteSystem---}------------------------------ helper functions--infix 1 <=>-(<=>) :: Bool -> Bool -> Bool-(<=>) = (==)--sameSet :: Ord a => [a] -> [a] -> Bool-sameSet a b = sort a == sort b-{--timeOut2s :: a -> IO a-timeOut2s x = do-    r <- timeOut 2 (return x)-    case r of-        NonTermination      -> error "nontermination"-        Value x             -> return x-        Exception e         -> error (show e)--}---------------------------- Serial instances--instance Serial Expr where-    series-        =  cons1 SCons-        \/ cons2 SFun-        \/ cons1 SLit-        \/ cons1 SHole-        \/ cons1 (SRef . natToInt)-        \/ cons2 SApp--newtype DataExpr-    = DataExpr { unDataExpr :: Expr }-        deriving Show--instance Serial DataExpr where-    series-        =  cons1 (DataExpr . SCons)-        \/ cons2 (\x -> DataExpr . SFun x)-        \/ cons1 (DataExpr . SLit)-        \/ cons1 (DataExpr . SRef . natToInt)-        \/ cons2 (\(DataExpr x) ys -> DataExpr $ SApp x $ map unDataExpr ys)--newtype DataGraph-    = DataGraph Graph-        deriving Show--instance Serial DataGraph where-    series = cons1 (DataGraph . IM.fromList . zip [0..] . map unDataExpr)--data Nat-    = Zero-    | Succ Nat-        deriving (Eq, Ord, Show)--instance Num Nat where-    fromInteger 0 = Zero-    fromInteger n | n < 0 = error "fromInteger/Num"-    fromInteger n = Succ (fromInteger (n-1))--    (+) = undefined-    (*) = undefined-    abs = undefined-    signum = undefined--instance Serial Nat where-    series = cons0 Zero \/ cons1 Succ--natToInt :: Nat -> Int-natToInt Zero = 0-natToInt (Succ n) = 1 + natToInt n-------------------------------------data PointedGraph-    = PGraph Expr Graph-        deriving (Show)--instance Serial PointedGraph where-    series = cons1 mkDataGraph--mkDataGraph :: Nat -> PointedGraph-mkDataGraph n = PGraph (SLit "15") IM.empty----------------------------- auxiliary predicates and functions--dataExpr :: Expr -> Bool-dataExpr (SHole _)   = False-dataExpr (SApp e es) = dataExpr e && all dataExpr es-dataExpr _           = True--dataGraph :: Graph -> Bool-dataGraph g = all dataExpr (IM.elems g)--ref :: Expr -> Bool-ref (SRef _) = True-ref _        = False--collectRefs :: Expr -> [Int]-collectRefs (SRef i)    = [i]-collectRefs (SApp e es) = collectRefs e ++ concatMap collectRefs es-collectRefs _           = []--allReferenceDefined :: Expr -> Graph -> Bool-allReferenceDefined e g = all (`IM.member` g) (collectRefs e ++ concatMap collectRefs (IM.elems g))-------------------------------allTests :: IO ()-allTests = do--    let-        p (SCons _)  = True-        p (SFun _ _) = True-        p (SLit _)   = True-        p _          = False--    smallCheck 30 $ \(PGraph e g) -> -- unsafePerformIO $ timeOut2s $-            not (ref e) && allReferenceDefined e g  ==>  p (fst (flattenSApp e g))--{--    sm $ interpreter "start = f True; f x = x" == "True"--    sm $ \s1 s2 s3 ->   s1 /= s2-            ==>  freeVars (s1 ++ " = 3;" ++ s2 ++ " " ++ s3 ++ " = " ++ s3)-                    `sameSet` [s1, s2]--}--
GraphRewrite/Main.hs view
@@ -1,6 +1,5 @@ ---import Paths_visual_graphrewrite (version)-+import Paths_visual_graphrewrite (version)  import GraphRewrite.Internal.Convert import GraphRewrite.Internal.Rename@@ -17,12 +16,13 @@ import qualified Graphics.Rendering.Cairo.SVG as C  import Text.PrettyPrint-import Data.Graph.Inductive+import Data.Graph.Inductive hiding (version)  import Language.Haskell.Parser -- parseModule import IPPrint --pprint import System.Environment --getArgs import Data.Supply+import qualified Data.Version  import qualified Data.Map as D import qualified Data.IntMap as I@@ -59,7 +59,7 @@   args <- getArgs   options <- parseOptions args   if showVersion options-    then putStrLn $ "version " -- ++ Data.Version.showVersion version+    then putStrLn $ "version " ++ Data.Version.showVersion version     else do       tmp <- readInput (inputFile options)       let mod = parseModule tmp
visual-graphrewrite.cabal view
@@ -1,6 +1,5 @@- name:                visual-graphrewrite-version:             0.3+version:             0.3.1 synopsis:            Visualize the graph-rewrite steps of a Haskell program description:         Visualize the graph-rewrite steps of a Haskell program. Currently it only shows the right-hand-sides of rewrite rules (function alternatives). category:            Development@@ -9,30 +8,55 @@ author:              Zsolt Dollenstein maintainer:          zsol@elte.hu homepage:            http://github.com/zsol/visual-graphrewrite/+bug-reports:         http://github.com/zsol/visual-graphrewrite/issues build-type:          Simple+tested-with:         GHC==6.10.2 cabal-version:       >= 1.6-build-Depends:       base >= 4.1.0.0,-                     containers >= 0.2.0.0,-                     value-supply >= 0.5,-                     lazysmallcheck >= 0.3,-                     haskell-src >= 1.0.1.2,-                     ipprint >= 0.3,-                     strict-concurrency >= 0.2.1,-                     parallel >= 1.1.0.1,-                     directory >= 1.0.0.3,-                     process >= 1.0.1.1,-                     fgl >= 5.4.2.2,-                     pretty >= 1.0.1.0,-                     gtk >= 0.10.0,-                     svgcairo >= 0.10.0,-                     cairo >= 0.10.0-extensions:          PatternGuards-extra-source-files:  sample/*.hs+data-files:          sample/*.hs                      GraphRewrite/Debug.hs -executable:          visual-graphrewrite-main-is:             GraphRewrite/Main.hs-other-modules:       GraphRewrite,++library+        exposed-modules:  GraphRewrite+        exposed-modules:  GraphRewrite.Internal.Rename+        exposed-modules:  GraphRewrite.Internal.SimpleHaskell+        exposed-modules:  GraphRewrite.Internal.Convert+        exposed-modules:  GraphRewrite.Internal.RewriteApp+        exposed-modules:  GraphRewrite.Internal.RewriteTypes+        exposed-modules:  GraphRewrite.Internal.Rewrite+        exposed-modules:  GraphRewrite.Internal.DeltaFunctions++        build-depends:    base >= 4.1.0.0+        build-depends:    containers >= 0.2.0.0+        build-depends:    value-supply >= 0.5+        build-depends:    lazysmallcheck >= 0.3+        build-depends:    haskell-src >= 1.0.1.2+        build-depends:    ipprint >= 0.3+        build-depends:    fgl >= 5.4.2.2+        build-depends:    pretty >= 1.0.1.0+        other-modules:    GraphRewrite.Main.CmdLineOpts,+                          GraphRewrite.Main.Visualize+        ghc-options:      -Wall -fno-warn-name-shadowing -fno-warn-incomplete-patterns+++executable visual-graphrewrite+        build-depends:    base >= 4.1.0.0+        build-depends:    containers >= 0.2.0.0+        build-depends:    value-supply >= 0.5+        build-depends:    lazysmallcheck >= 0.3+        build-depends:    haskell-src >= 1.0.1.2+        build-depends:    ipprint >= 0.3+        build-depends:    strict-concurrency >= 0.2.1+        build-depends:    parallel >= 1.1.0.1+        build-depends:    directory >= 1.0.0.3+        build-depends:    process >= 1.0.1.1+        build-depends:    fgl >= 5.4.2.2+        build-depends:    pretty >= 1.0.1.0+        build-depends:    gtk >= 0.10.0+        build-depends:    svgcairo >= 0.10.0+        build-depends:    cairo >= 0.10.0+        main-is:    GraphRewrite/Main.hs+        other-modules:       GraphRewrite,                      GraphRewrite.Internal.Rename,                      GraphRewrite.Internal.SimpleHaskell,                      GraphRewrite.Internal.Convert,@@ -40,9 +64,9 @@                      GraphRewrite.Internal.RewriteTypes,                      GraphRewrite.Internal.Rewrite,                      GraphRewrite.Internal.DeltaFunctions,-                     GraphRewrite.Internal.Test,                      GraphRewrite.Main.CmdLineOpts,                      GraphRewrite.Main.Visualize+        ghc-options:      -Wall -fno-warn-name-shadowing -fno-warn-incomplete-patterns -ghc-options:         -Wall -fno-warn-name-shadowing -fno-warn-incomplete-patterns+