
10 Oct
2008
10 Oct
'08
9:03 a.m.
On Mon, 6 Oct 2008, Jean-Philippe Bernardy wrote:
How about capturing the pattern in higher order functions?
if we define:
import Data.Function import Data.List
data Cache b a = Cache b a fromCache (Cache _ a) = a toCache f a = Cache (f a) a cache (Cache b _) = b
caching f g = map fromCache . g . map (toCache f)
I've already done this with plain pairs - a distinct type like Cache is of course better. See attachKey: http://darcs.haskell.org/htam/src/Useful.hs