diff options
Diffstat (limited to 'sucl')
-rw-r--r-- | sucl/graph.dcl | 3 | ||||
-rw-r--r-- | sucl/graph.icl | 23 |
2 files changed, 12 insertions, 14 deletions
diff --git a/sucl/graph.dcl b/sucl/graph.dcl index 1ed9c29..eef57a7 100644 --- a/sucl/graph.dcl +++ b/sucl/graph.dcl @@ -2,6 +2,7 @@ definition module graph // $Id$ +from pfun import Pfun from StdOverloaded import == // A rule associating a replacement with a pattern @@ -214,4 +215,6 @@ compilegraph :: ![(var,Node sym var)] -> Graph sym var */ +extgraph :: (Graph sym var) (Graph sym pvar) [pvar] (Pfun pvar var) (Graph sym var) -> Graph sym var | == var & == pvar + instance == (Graph sym var) | == sym & == var diff --git a/sucl/graph.icl b/sucl/graph.icl index 40d153e..8812b9a 100644 --- a/sucl/graph.icl +++ b/sucl/graph.icl @@ -359,22 +359,17 @@ Uses in Miranda: `Extgraph' is excluded in most import statements, but there doesn't seem to be any other definition of it. - -> extgraph :: graph * ** -> graph * *** -> [***] -> pfun *** ** -> graph * ** -> graph * ** -> extgraph sgraph pattern pnodes matching graph -> = foldr addnode graph pnodes -> where addnode pnode -> = total id (postcomp addnode' matching) pnode, if fst (nodecontents pattern pnode) -> = id, otherwise -> addnode' snode -> = updategraph snode scont, if sdef -> = id, otherwise ->|| = error "extgraph: closed node mapped to open node", otherwise -> || Could have used id, but let's report error when there is one... -> where (sdef,scont) = nodecontents sgraph snode - */ +extgraph :: (Graph sym var) (Graph sym pvar) [pvar] (Pfun pvar var) (Graph sym var) -> Graph sym var | == var & == pvar +extgraph sgraph pattern pnodes matching graph += foldr addnode graph pnodes + where addnode pnode + = if (fst (varcontents pattern pnode)) (total id (postcomp addnode` matching) pnode) id + addnode` snode + = if sdef (updategraph snode scont) id + where (sdef,scont) = varcontents sgraph snode + mapgraph :: !( (Pfun var1 (sym1,[var1])) -> Pfun .var2 (.sym2,[.var2]) |