[Haskell-cafe] A small puzzle: inTwain as function of foldr

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Jun 5 07:37:04 EDT 2009


Geoffrey Marchant wrote:
> The linked paper appears to show the right style.
> 
> This appears to satisfy the conditions, however:
> 
> inTwain as = let (x,y,_) = foldr (\a (r,s,t) -> case (t) of {b:(b':bs) 
> -> (r,a:s,bs); _ -> (a:r,s,t)}) ([],[],as) as in (x,y)

This one is very interesting. Thanks. :-) It took a while to see what is 
going on.

I'm not too happy with the whole list as part of the initial state. That 
feels like cheating to me--although I obviously failed to specify this 
in my original question. Trying to understand morphisms: does that make 
this a paramorphism rather than a catamorphism?

Martijn.



More information about the Haskell-Cafe mailing list