diff options
-rw-r--r-- | sucl/basic.dcl | 4 | ||||
-rw-r--r-- | sucl/basic.icl | 20 | ||||
-rw-r--r-- | sucl/loop.icl | 5 | ||||
-rw-r--r-- | sucl/spine.dcl | 2 | ||||
-rw-r--r-- | sucl/strat.icl | 5 |
5 files changed, 21 insertions, 15 deletions
diff --git a/sucl/basic.dcl b/sucl/basic.dcl index 664f5fd..b288043 100644 --- a/sucl/basic.dcl +++ b/sucl/basic.dcl @@ -14,6 +14,7 @@ Basic types and functions. */ +from general import Optional import StdOverloaded import StdString @@ -26,7 +27,8 @@ Implementation // The optional type of type t is a type like t // where the actual t value may be present or absent. -:: Optional t = Absent | Present t +//:: Optional t = Absent | Present t +//Now using Optional from cocl's general module // Adjust a function for a single argument diff --git a/sucl/basic.icl b/sucl/basic.icl index 40588fe..86770b5 100644 --- a/sucl/basic.icl +++ b/sucl/basic.icl @@ -23,7 +23,9 @@ Implementation */ -:: Optional t = Absent | Present t +//:: Optional t = Absent | Present t +// Now using Optional type from cocl's general module +from general import Optional,No,Yes // Adjust a function for a single argument @@ -91,8 +93,8 @@ foldmap f d where foldmap` (x,y) g v = if (x==v) (f y) (g v) foldoptional :: .res .(.t -> .res) !(Optional .t) -> .res -foldoptional absent present Absent = absent -foldoptional absent present (Present x) = present x +foldoptional no yes No = no +foldoptional no yes (Yes x) = yes x forget :: val -> .(![.(val,res)] -> .[(val,res)]) | == val forget x = filter (neq x o fst) @@ -161,8 +163,8 @@ power n f = f o power (n-1) f printoptional :: .(.t -> String) !(Optional .t) -> String -printoptional printa Absent = "" -printoptional printa (Present a) = printa a +printoptional printa No = "" +printoptional printa (Yes a) = printa a proc :: .((w:elem -> .(.res -> .res)) -> v:(![w:elem] -> u:(.res -> .res))), [u <= v, u <= w] proc = flip o foldr @@ -178,8 +180,8 @@ maphd f [] = [] maphd f [x:xs] = [f x:xs] mapoptional :: .(.a -> .b) !(Optional .a) -> Optional .b -mapoptional f Absent = Absent -mapoptional f (Present x) = Present (f x) +mapoptional f No = No +mapoptional f (Yes x) = Yes (f x) mappair :: .(.a -> .b) .(.c -> .d) !(.a,.c) -> (.b,.d) mappair f g (x,y) = (f x,g y) @@ -219,8 +221,8 @@ showbool :: .(!.Bool -> a) | fromBool a showbool = fromBool showoptional :: .(.a -> .String) !(Optional .a) -> String -showoptional showa Absent = "Absent" -showoptional showa (Present a) = "(Present "+++showa a+++")" +showoptional showa No = "No" +showoptional showa (Yes a) = "(Yes "+++showa a+++")" showpair :: !.(.a -> .String) !.(.b -> .String) !(.a,.b) -> String showpair showa showb (a,b) = "("+++showa a+++","+++showb b+++")" diff --git a/sucl/loop.icl b/sucl/loop.icl index 39c9f9e..0ecb18d 100644 --- a/sucl/loop.icl +++ b/sucl/loop.icl @@ -11,6 +11,7 @@ import rule import graph import pfun import basic +from general import Yes,No import StdEnv /* @@ -134,14 +135,14 @@ transform | == var & == pvar -transform anode sargs (Present spine) +transform anode sargs (Yes spine) = selectfromtip (spinetip spine) where selectfromtip (nid,Open rgraph) = tryinstantiate nid rgraph anode sargs selectfromtip (nid,Redex rule matching) = tryunfold nid rule matching spine selectfromtip (nid,Strict) = tryannotate nid sargs selectfromtip spine = dostop -transform anode sargs Absent +transform anode sargs No = dostop // ==== ATTEMPT TO INSTANTIATE A FREE VARIABLE WITH A PATTERN ==== diff --git a/sucl/spine.dcl b/sucl/spine.dcl index 5e9c56b..e2b35b0 100644 --- a/sucl/spine.dcl +++ b/sucl/spine.dcl @@ -4,7 +4,7 @@ definition module spine from rule import Rgraph,Rule from pfun import Pfun -from basic import Optional +from general import Optional /* diff --git a/sucl/strat.icl b/sucl/strat.icl index cc49256..8d1d469 100644 --- a/sucl/strat.icl +++ b/sucl/strat.icl @@ -9,6 +9,7 @@ import rule import graph import pfun import basic +from general import No,Yes import StdEnv /* @@ -110,8 +111,8 @@ makernfstrategy makernfstrategy hist strat rnfnodes node graph = substrat [] spinecont rnfanswer node - where spinecont spine = Present spine - rnfanswer = Absent + where spinecont spine = Yes spine + rnfanswer = No substrat spinenodes spinecont rnfanswer node | isMember node spinenodes |