[Haskell-cafe] Memoization in Haskell?

Daniel Fischer daniel.is.fischer at web.de
Fri Jul 9 07:17:13 EDT 2010

On Friday 09 July 2010 01:03:48, Luke Palmer wrote:
> On Thu, Jul 8, 2010 at 4:23 PM, Daniel Fischer <daniel.is.fischer at web.de> 
> > On Friday 09 July 2010 00:10:24, Daniel Fischer wrote:
> >> You can also use a library (e.g.
> >> http://hackage.haskell.org/package/data- memocombinators) to do the
> >> memoisation for you.
> >
> > Well, actualy, I think http://hackage.haskell.org/package/MemoTrie
> > would be the better choice for the moment, data-memocombinators
> > doesn't seem to offer the functionality we need out of the box.
> I'm interested to hear what functionality MemoTrie has that
> data-memocombinators does not.  I wrote the latter in hopes that it
> would be strictly more powerful*.

It's probably my night-blindness, but I didn't see an immediate way to 
memoise a simple function on a short look at the docs, like

memo :: (ConstraintOn a) => (a -> b) -> a -> b

, which Data.MemoTrie provides (together with memo2 and memo3, which data-
memocombinators provide too).

Taking a closer look at the docs in daylight, I see data-mc provides that 
out of the box too, the stuff is just differently named (bool, char, 
integral, ...) - which I didn't expect.

So you could take it as an indication that I'm visually impaired, or as an 
indication that the docs aren't as obvious as they could be.

> Luke
> * Actually MemoTrie wasn't around when I wrote that, but I meant the
> combinatory technique should be strictly more powerful than a
> typeclass technique.  And data-memocombinators has many primitives, so
> I'm still curious.

More information about the Haskell-Cafe mailing list