Utils.hs revision e6d40133bc9f858308654afb1262b8b483ec5922
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeModule :$Header$
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerDescription : utilities for Hets commands
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian MaederCopyright : uni-bremen and Razvan Pascanu
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeLicence : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : r.pascanu@iu-bremen.de
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeStability : provisional
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkePortability : portable
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeToghether with PGIP.Common, PGIP.Utils contains all the auxiliary functions
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartkeused throughout the interactive interface. The reason for dividing these
501e4e6b8288a5b73d7d4b8d8b80817f9bf8e60fJonathan von Schroederfunctions in two files was that otherwise we would've get a circular
501e4e6b8288a5b73d7d4b8d8b80817f9bf8e60fJonathan von Schroederinclusion (for example Proof.Automatic requieres some of these auxiliary
501e4e6b8288a5b73d7d4b8d8b80817f9bf8e60fJonathan von Schroederfunctions, but some other functions -- that appear now in PGIP.Common --
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartkerequire some functions from Proof.Automatic)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maedertype GDataEdge = LEdge DGLinkLab
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maedertype GDataNode = LNode DGNodeLab
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maederdata GraphGoals =
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder GraphNode GDataNode
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder | GraphEdge GDataEdge
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder deriving (Eq,Show)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder-- | The datatype GOAL contains all the information read by the parser from the
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke | Edge String String
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder | LabeledEdge String Int String
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke deriving (Eq,Show)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke-- | The function 'getGoalList' creates a graph goal list ( a graph goal is
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder-- defined by the datatype 'GraphGoals') that is a part of the list passed
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke-- as an argument that corresponds to the parsed goals ( see
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke-- 'GOAL' datatype)
1a38107941725211e7c3f051f7a8f5e12199f03acmaedergetGoalList :: [GOAL] -> [GraphGoals] -> [GraphGoals] -> IO [GraphGoals]
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von SchroedergetGoalList goalList allg ll
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke = case goalList of
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder (Node x):l -> do
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder tmp <- extractGraphNode x allg
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke tmp2<- getGoalList l allg ll
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Just smth -> return (smth:tmp2)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Nothing -> do
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder putStr ("Couldn't find node "++x++"\n")
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke (Edge x y):l -> do
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke tmp <- extractGraphEdge x y allg ll
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke tmp2<- getGoalList l allg ll
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke Just smth -> return (smth:tmp2)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Nothing -> return tmp2
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke (LabeledEdge x nb y):l -> do
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke tmp <- extractGraphLabeledEdge x nb y allg ll
656f17ae9b7610ff2de1b6eedeeadea0c3bcdc8dChristian Maeder tmp2<- getGoalList l allg ll
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Just smth -> return (smth:tmp2)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke Nothing -> return tmp2
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder [] -> return []
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder-- | The function 'extractGraphNode' extracts the goal node defined by
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke-- the ID of the node as a string from the provided list of goals
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeextractGraphNode:: String->[GraphGoals]->IO (Maybe GraphGoals)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus HartkeextractGraphNode x allGoals
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke = case allGoals of
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke return Nothing
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke (GraphNode (nb,label)):l -> do
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke if (( getDGNodeName label)==x)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke then return (Just (GraphNode (nb,label)))
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder else extractGraphNode x l
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke _:l -> extractGraphNode x l
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke-- | The function 'extractGraphEdge' extracts the goal edge determined by
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder-- the two nodes from the provided list of goals
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von SchroederextractGraphEdge:: String -> String -> [GraphGoals] -> [GraphGoals]
a23e572c8f957cc051a1b0831abd6fe9380d45c7Christian Maeder -> IO (Maybe GraphGoals)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian MaederextractGraphEdge x y allGoals ll
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder = case allGoals of
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder return Nothing
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder (GraphEdge (xx,yy,label)):l -> do
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder ttt1 <- extractGraphNode x ll
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke ttt2 <- extractGraphNode y ll
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke case ttt1 of
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke Nothing -> do
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke putStr ("Couldn't find node "++x++"\n"++
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke "when looking for edge "++x++" -> "++y++"\n")
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke return Nothing
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke Just t1 -> do
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke case ttt2 of
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Nothing -> do
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder putStr ("Couldn't find node "++y++"\n"++
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder "when looking for edge "++x++" -> "++y++"\n")
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder return Nothing
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Just t2 -> do
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder (GraphNode (tmp1_nb, _)) ->
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke (GraphNode (tmp2_nb, _)) ->
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder if (tmp1_nb == xx)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke then if (tmp2_nb == yy)
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke then return (Just (GraphEdge (xx,yy,label)))
9f93539f2fa4f5b9d935c7baa22fcd750806def9Klaus Hartke else extractGraphEdge x y l ll