fsmActions 0.4.3 → 0.4.4
raw patch · 4 files changed
+8/−55 lines, 4 filesdep ~fgldep ~graphvizPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: fgl, graphviz
API changes (from Hackage documentation)
- Data.FsmActions.Graph: class Show a => CleanShow a
- Data.FsmActions.Graph: cleanShow :: CleanShow a => a -> String
- Data.FsmActions.Graph: fsmToGML :: CleanShow sy => FSM sy -> Doc
- Data.FsmActions.Graph: instance [overlap ok] CleanShow ()
- Data.FsmActions.Graph: instance [overlap ok] CleanShow Char
- Data.FsmActions.Graph: instance [overlap ok] CleanShow String
- Data.FsmActions.Graph: instance [overlap ok] Show a => CleanShow a
- Data.FsmActions.Graph: fglDot :: (Ord b, CleanShow b, Graph gr) => gr a b -> DotGraph Int
+ Data.FsmActions.Graph: fglDot :: (Ord b, Labellable b, Graph gr) => gr a b -> DotGraph Int
- Data.FsmActions.Graph: fsmToDot :: (Ord sy, CleanShow sy) => FSM sy -> DotGraph Int
+ Data.FsmActions.Graph: fsmToDot :: (Ord sy, Labellable sy) => FSM sy -> DotGraph Int
Files
- Data/FsmActions/FsmEdges.hs +2/−2
- Data/FsmActions/Graph.hs +3/−50
- doc/fsmActions.pdf binary
- fsmActions.cabal +3/−3
Data/FsmActions/FsmEdges.hs view
@@ -99,8 +99,8 @@ ppFsmEdges :: FSM String -> Doc ppFsmEdges fsm = ppFsmEdges' $ map tweakEdge $ G.labEdges $ fsmToFGL fsm Trim where -- Convert fgl-format Edge to the ones used by this module.- tweakEdge :: CleanShow sy => G.LEdge sy -> Edge- tweakEdge (s, d, l) = Edge (toInteger s) (toInteger d) (cleanShow l)+ tweakEdge :: G.LEdge String -> Edge+ tweakEdge (s, d, l) = Edge (toInteger s) (toInteger d) l ppFsmEdges' :: [Edge] -> Doc ppFsmEdges' = braces . vcat . punctuate comma . map ppFsmEdge ppFsmEdge :: Edge -> Doc
Data/FsmActions/Graph.hs view
@@ -22,7 +22,6 @@ {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverlappingInstances #-} module Data.FsmActions.Graph ( -- * FGL graph operations.@@ -32,10 +31,7 @@ strongCCs, weakCCs, -- * Dot and GML format output.- CleanShow,- cleanShow, fsmToDot,- fsmToGML, -- * Input. fglToFsm ) where@@ -50,7 +46,6 @@ import Data.List (nub, sort) import qualified Data.Map as M import Data.Map.Utils (forceLookupM)-import Text.PrettyPrint.HughesPJ import Data.FsmActions hiding (mkAction) import Data.FsmActions.Error@@ -123,62 +118,20 @@ --- | Subclass 'Show' so that 'show' calls on 'String's and 'Char's--- don't get quotes inserted.-class (Show a) => CleanShow a where- cleanShow :: a -> String- cleanShow = show -- by default, turn it to a String-instance (Show a) => CleanShow a-instance CleanShow () where- cleanShow _ = ""-instance CleanShow String where- cleanShow = id -- don't need to do anything for a String-instance CleanShow Char where- cleanShow c = cleanShow [c] -- just lift it to String--- -- | Turn an FSM into a 'Data.GraphViz.DotGraph', trimming any -- self-loops which aren't sources of nondeterminism.-fsmToDot :: (Ord sy, CleanShow sy) => FSM sy -> DotGraph Int+fsmToDot :: (Ord sy, Labellable sy) => FSM sy -> DotGraph Int fsmToDot = fglDot . flip fsmToFGL Trim -- Turn an FGL into a DotGraph with labelled edges.-fglDot :: (Ord b, CleanShow b, Graph gr) => gr a b -> DotGraph Int+fglDot :: (Ord b, Labellable b, Graph gr) => gr a b -> DotGraph Int fglDot g = graphToDot parms g where parms = nonClusteredParams { isDirected = True , fmtNode = const [] , fmtEdge = edgeFn }- edgeFn (_, _, label) = [Label $ StrLabel $ cleanShow label]------ | Turn an FSM into a GML-formatted graph', trimming any self-loops--- which aren't sources of nondeterminism.-fsmToGML :: CleanShow sy => FSM sy -> Doc-fsmToGML f = text "graph" <+> brackets body- where body = vcat [directed, planar, fNodes, fEdges]- directed = text "directed 1"- planar = text "IsPlanar 1"- fNodes = vcat $ map gmlNode $ states f- fEdges = vcat $ map gmlEdge $ labEdges $ fsmToFGL f Trim--gmlNode :: State -> Doc-gmlNode i =- text "node" <+> brackets (vcat [- text "id" <+> text (show i),- text "label" <+> doubleQuotes (text $ show i)- ])--gmlEdge :: CleanShow sy => (State, State, sy) -> Doc-gmlEdge (src, dest, label) =- text "edge" <+> brackets (vcat [- text "source" <+> text (show src),- text "target" <+> text (show dest),- text "label" <+> doubleQuotes (text $ cleanShow label)- ])+ edgeFn (_, _, label) = [toLabel label]
doc/fsmActions.pdf view
binary file changed (215660 → 216013 bytes)
fsmActions.cabal view
@@ -1,5 +1,5 @@ Name: fsmActions-Version: 0.4.3+Version: 0.4.4 Stability: Alpha Synopsis: Finite state machines and FSM actions Description:@@ -26,8 +26,8 @@ Library Build-Depends: base >= 3 && < 5, containers, filepath,- fgl >= 5.4.2.3,- graphviz >= 2999.11.0.0,+ fgl >= 5.4.2.0,+ graphviz >= 2999.14.0.0, MissingH, mtl, parsec >= 3, pretty Exposed-modules: Data.FsmActions, Data.FsmActions.ActionMatrix,