aboutsummaryrefslogtreecommitdiff
path: root/sucl/history.icl
blob: b39b6e316db4eb33a77f5639fb1e31c81ca9409d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
implementation module history

// $Id$

import spine
import rule
import graph
import basic
import StdEnv

:: History sym var
   :== [(var,[Rgraph sym var])]

/*

>   history * ** == [(**,[rgraph * **])]

>   showhistory :: (*->[char]) -> (**->[char]) -> history * ** -> [char]
>   showhistory showa showb = showlist (showpair showb (showlist (showrgraph showa showb)))

>   printhistory :: (*->[char]) -> (**->[char]) -> history * ** -> [[char]]
>   printhistory showa showb
>   =   concat.map print
>       where print (node,rgraphs)
>             =   showb node:map2 (++) ("<=  ":repeat "    ") (map (printrgraph showa showb) rgraphs)

*/

extendhistory
 :: (Graph sym var)
    (var -> var)
    (Spine sym var pvar)
    (History sym var)
 -> History sym var

extendhistory sgraph redirection spine history
= snd (foldspine (extendpair sgraph redirection) d d id d (const d) (extendpartial sgraph) (const d) (extendredex sgraph history) d spine)
  where d = (emptygraph,history)

/*

>   extendpair :: graph * ** -> (**->**) -> ** -> (graph * **,history * **) -> (graph * **,history * **)
>   extendpair sgraph redirect snode (hgraph,history)
>   =   (hgraph',remap (redirect snode) (mkrgraph snode hgraph':foldmap id [] history snode) (forget snode history))
>       where hgraph' = cond sdef (updategraph snode scont hgraph) hgraph
>             (sdef,scont) = dnc (const "in extendpair") sgraph snode

*/

extendpair
 :: (Graph sym var)
    (var->var)
    var
    (Graph sym var,History sym var)
 -> (Graph sym var,History sym var)

extendpair _ _ _ _ = undef

/*

>   extendpartial :: graph * ** -> rule * *** -> pfun *** ** -> (graph * **,history * **) -> (graph * **,history * **)
>   extendpartial sgraph rule matching (hgraph,history)
>   =   (extgraph' sgraph rule matching hgraph,history)

*/

extendpartial
 :: (Graph sym var)
    (Rule sym pvar)
    (Pfun pvar var)
    (Graph sym var,History sym var)
 -> (Graph sym var,History sym var)

extendpartial _ _ _ _ = undef

/*

>   extendredex :: graph * ** -> history * ** -> rule * *** -> pfun *** ** -> (graph * **,history * **)
>   extendredex sgraph history rule matching
>   =   (extgraph' sgraph rule matching emptygraph,history)

*/

extendredex
 :: (Graph sym var)
    (History sym var)
    (Rule sym pvar)
    (Pfun pvar var)
 -> (Graph sym var,History sym var)

extendredex _ _ _ _ = undef

/*

>   extgraph' sgraph rule
>   =   extgraph sgraph rgraph (nodelist rgraph (lhs rule))
>       where rgraph = rulegraph rule

*/