The stable-memo package

[ Tags: data, library, mit ] [ Propose Tags ]

Whereas most memo combinators memoize based on equality, stable-memo does it based on whether the exact same argument has been passed to the function before (that is, is the same argument in memory).

For motivation, here is an implementation of map that preserves sharing of the spine for cyclic lists. It should even be safe to use this on arbitrarily long, acyclic lists since as long as the garbage collector is chasing you, the size of the memo table should stay under control, too.

map :: (a -> b) -> [a] -> [b]
map f = go
  where go = memo map'
        map' []     = []
        map' (x:xs) = f x : go xs

This library is largely based on the implementation of memo found in "Stretching the storage manager: weak pointers and stable names in Haskell", from Simon Peyton Jones, Simon Marlow, and Conal Elliott (http://community.haskell.org/~simonmar/papers/weak.pdf).

Properties

Versions 0.1.1, 0.1.2, 0.1.3, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1
Dependencies base (>=4.6 && <5), ghc-prim (>=0.3 && <0.6), hashtables (>=1.0 && <1.3) [details]
License MIT
Author Jake McArthur <Jake.McArthur@gmail.com>
Maintainer Jake McArthur <Jake.McArthur@gmail.com>
Category Data
Source repository head: darcs get http://hub.darcs.net/jmcarthur/stable-memo
this: darcs get http://patch-tag.com/r/jmcarthur/stable-memo --tag v0.3.1
Uploaded Sun Jul 12 19:27:24 UTC 2015 by JakeMcArthur
Updated Sun Apr 2 15:47:59 UTC 2017 by JakeMcArthur to revision 1
Distributions NixOS:0.3.1
Downloads 2041 total (15 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-07-12 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees