I play with functions recursion-schemesand struggle to find out if it offers something generalized mapAccumR. Something powerful enough to implement, for example:
f :: [Int] -> (Int,[Int])
f [] = (0,[])
f (x:xs) = let (sz,xs') = f xs in (sz+x, x*sz : xs')
... in one pass for the Fix-ed structure , for example:
data L a as = Empty | C a as
input :: Fix (L Int)
input = Fix (C 1 (Fix (C 2 (Fix Empty))))
zygoIt seems almost what I want, except that I need access to the final one b(the final amount in the example above).
My actual use case is an AST type check on annotations and an expression type return.
source
share