data-memocombinators-0.1: Combinators for building memo tables.

Portabilitypresumably portable
Stabilityexperimental
MaintainerLuke Palmer <lrpalmer@gmail.com>

Data.MemoCombinators

Description

This module provides combinators for building memo tables over various data types, so that the type of table can be customized depending on the application.

Synopsis

Documentation

type Memo a = forall r. (a -> r) -> a -> rSource

The type of a memo table.

memo2 :: Memo a -> Memo b -> (a -> b -> r) -> a -> b -> rSource

Memoize a two argument function (just apply the table directly for single argument functions).

memo3 :: Memo a -> Memo b -> Memo c -> (a -> b -> c -> r) -> a -> b -> c -> rSource

Memoize a three argument function.

memoSecond :: Memo b -> (a -> b -> r) -> a -> b -> rSource

Memoize the second argument of a function.

memoThird :: Memo c -> (a -> b -> c -> r) -> a -> b -> c -> rSource

Memoize the third argument of a function.

bool :: Memo BoolSource

A memo table for bools.

type RangeMemo a = a -> a -> Memo aSource

The type of builders for ranged tables; takes a lower bound and an upper bound, and returns a memo table for that range. The table's behavior is undefined for values outside that range.

arrayRange :: Ix a => RangeMemo aSource

Build a memo table for a range using a flat array.

chunks :: Ix a => RangeMemo a -> [(a, a)] -> Memo aSource

Given a list of ranges, (lazily) build a memo table for each one and combine them using linear search.