Commit 6a89fb89 authored by bbr's avatar bbr
Browse files

propagate now also gets info which number the argument is

parent 6c97f477
......@@ -487,10 +487,11 @@ curryInstance opts t@(Type origName vis vars consdecls)
propRule (Cons cname arity _ _) =
C.Rule (addStatePat [C.PVar "f",C.PComb (consName opts cname) (map toPVar [1..arity])])
C.Rule (addStatePat [C.PVar "f",C.PComb (consName opts cname)
(map toPVar [1..arity])])
(noguard $ fapp (sym (consName opts cname))
(map (fapp (C.Var "f") . addStateArg . (:[]) . toVar)
[1 .. arity])) []
(map propCall [1 .. arity])) []
where propCall i = fapp (C.Var "f") (addStateArg [toInt (i-1),toVar i])
foldCurry = C.Func (newModName,"foldCurry") (transvis vis) untyped
(Just (map foldRule consdecls))
......
......@@ -23,7 +23,7 @@ class (BaseCurry a,Show a,Read a) => Curry a where
eq :: a -> a -> Result C_Bool
-- some generics
propagate :: (forall b. Curry b => b -> Result b) -> a -> Result a
propagate :: (forall b. Curry b => Int -> b -> Result b) -> a -> Result a
foldCurry :: (forall c. Curry c => c -> b -> Result b) -> b -> a -> Result b
-- name of the type
......@@ -635,7 +635,7 @@ instance (Curry t0) => Curry (DataPrelude.List t0) where
eq _ _ _ = DataPrelude.C_False
propagate f DataPrelude.List st = DataPrelude.List
propagate f ((DataPrelude.:<) x1 x2) st = (DataPrelude.:<)(f(x1)(st))(f(x2)(st))
propagate f ((DataPrelude.:<) x1 x2) st = (DataPrelude.:<)(f 0 (x1)(st))(f 1 (x2)(st))
foldCurry f c DataPrelude.List st = c
foldCurry f c ((DataPrelude.:<) x1 x2) st = f(x1)(f(x2)(c)(st))(st)
......@@ -720,7 +720,8 @@ instance Curry C_Char where
eq _ _ _ = C_False
propagate _ c@(C_Char _) _ = c
propagate f (SearchChar f0 f1 f2 f3) st = SearchChar (f f0 st) (f f1 st) (f f2 st) (f f3 st)
propagate f (SearchChar f0 f1 f2 f3) st =
SearchChar (f 0 f0 st) (f 1 f1 st) (f 2 f2 st) (f 3 f3 st)
foldCurry _ c (C_Char _) _ = c
foldCurry f c (SearchChar f0 f1 f2 f3) st = f f0 (f f1 (f f2 (f f3 c st)st)st)st
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment