stable-memo-0.2.4: Memoization based on argument identity

Copyright(c) 2012, 2014 Jake McArthur
LicenseMIT
MaintainerJake McArthur <Jake.McArthur@gmail.com>
Stabilityprovisional
PortabilityGHC
Safe HaskellSafe
LanguageHaskell2010

Data.StableMemo.Weak

Description

This module provides memo combinators with slightly different behavior from those in Data.StableMemo. The memo tables generated by these combinators use weak pointers to store the values, so they not only do not unnecessarily retain the arguments, but they also do not retain the function outputs. This can be useful for memoized functions that are expected to be around for a long time. If the result for an input has already been computed and happens to still be in the heap, it will be reused, otherwise it will be recomputed.

Synopsis

Documentation

memo :: (a -> b) -> a -> b Source

Memoize a unary function.

memo2 :: (a -> b -> c) -> a -> b -> c Source

Curried memoization to share partial evaluation

memo3 :: (a -> b -> c -> d) -> a -> b -> c -> d Source

Curried memoization to share partial evaluation

type (-->) f g = forall a. f a -> g a Source

Polymorphic memoizable function

memoPoly :: (f --> g) -> f --> g Source

Memoize a function with support for a certain form of polymorphic recursion.