-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Combinators for building memo tables.
--   
--   Combinators for building memo tables.
@package data-memocombinators
@version 0.5.1

-- | 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.
--   
--   This module is designed to be imported qualified, eg.
--   
--   
--   import qualified Data.MemoCombinators as Memo
--   
--   
--   Usage is straightforward: apply an object of type Memo a to a
--   function of type a -> b, and get a memoized function of
--   type a -> b. For example:
--   
--   
--   fib = Memo.integral fib'
--      where
--      fib' 0 = 0
--      fib' 1 = 1
--      fib' x = fib (x-1) + fib (x-2)
--   
module Data.MemoCombinators

-- | The type of a memo table for functions of a.
type Memo a = forall r. () => a -> r -> a -> r

-- | Given a memoizer for a and an isomorphism between a and b, build a
--   memoizer for b.
wrap :: (a -> b) -> (b -> a) -> Memo a -> Memo b

-- | Memoize a two argument function (just apply the table directly for
--   single argument functions).
memo2 :: Memo a -> Memo b -> (a -> b -> r) -> a -> b -> r

-- | Memoize a three argument function.
memo3 :: Memo a -> Memo b -> Memo c -> (a -> b -> c -> r) -> a -> b -> c -> r

-- | Memoize the second argument of a function.
memoSecond :: Memo b -> (a -> b -> r) -> a -> b -> r

-- | Memoize the third argument of a function.
memoThird :: Memo c -> (a -> b -> c -> r) -> a -> b -> c -> r
bool :: Memo Bool
char :: Memo Char
list :: Memo a -> Memo [a]

-- | Build a table which memoizes all lists of less than the given length.
boundedList :: Int -> Memo a -> Memo [a]
either :: Memo a -> Memo b -> Memo (Either a b)
maybe :: Memo a -> Memo (Maybe a)
unit :: Memo ()
pair :: Memo a -> Memo b -> Memo (a, b)

-- | Memoize an enum type.
enum :: Enum a => Memo a

-- | Memoize an integral type.
integral :: Integral a => Memo a

-- | Memoize an ordered type with a bits instance.
bits :: (Num a, Ord a, Bits a) => Memo a

-- | switch p a b uses the memo table a whenever p gives true and
--   the memo table b whenever p gives false.
switch :: (a -> Bool) -> Memo a -> Memo a -> Memo a

-- | The type of builders for ranged tables; takes a lower bound and an
--   upper bound, and returns a memo table for that range.
type RangeMemo a = (a, a) -> Memo a

-- | Build a memo table for a range using a flat array. If items are given
--   outside the range, don't memoize.
arrayRange :: Ix a => RangeMemo a

-- | Build a memo table for a range using a flat array. If items are given
--   outside the range, behavior is undefined.
unsafeArrayRange :: Ix a => RangeMemo a

-- | Given a list of ranges, (lazily) build a memo table for each one and
--   combine them using linear search.
chunks :: Ix a => RangeMemo a -> [(a, a)] -> Memo a

module Data.MemoCombinators.Class

-- | The class of types which have complete memo tables.
class MemoTable a
table :: MemoTable a => Memo a

-- | The class of functions which can be completely memoized.
class Memoizable a
memoize :: Memoizable a => a -> a
instance Data.MemoCombinators.Class.MemoTable GHC.Types.Bool
instance Data.MemoCombinators.Class.MemoTable GHC.Types.Char
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b) => Data.MemoCombinators.Class.MemoTable (GHC.Internal.Data.Either.Either a b)
instance Data.MemoCombinators.Class.MemoTable GHC.Types.Int
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Int.Int16
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Int.Int32
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Int.Int64
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Int.Int8
instance Data.MemoCombinators.Class.MemoTable GHC.Num.Integer.Integer
instance Data.MemoCombinators.Class.MemoTable a => Data.MemoCombinators.Class.MemoTable [a]
instance Data.MemoCombinators.Class.MemoTable a => Data.MemoCombinators.Class.MemoTable (GHC.Internal.Maybe.Maybe a)
instance Data.MemoCombinators.Class.MemoTable GHC.Types.Ordering
instance (GHC.Internal.Real.Integral a, Data.MemoCombinators.Class.MemoTable a) => Data.MemoCombinators.Class.MemoTable (GHC.Internal.Real.Ratio a)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j, Data.MemoCombinators.Class.MemoTable k) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j, k)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j, Data.MemoCombinators.Class.MemoTable k, Data.MemoCombinators.Class.MemoTable l) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j, k, l)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j, Data.MemoCombinators.Class.MemoTable k, Data.MemoCombinators.Class.MemoTable l, Data.MemoCombinators.Class.MemoTable m) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j, k, l, m)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j, Data.MemoCombinators.Class.MemoTable k, Data.MemoCombinators.Class.MemoTable l, Data.MemoCombinators.Class.MemoTable m, Data.MemoCombinators.Class.MemoTable n) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i, Data.MemoCombinators.Class.MemoTable j, Data.MemoCombinators.Class.MemoTable k, Data.MemoCombinators.Class.MemoTable l, Data.MemoCombinators.Class.MemoTable m, Data.MemoCombinators.Class.MemoTable n, Data.MemoCombinators.Class.MemoTable o) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b) => Data.MemoCombinators.Class.MemoTable (a, b)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c) => Data.MemoCombinators.Class.MemoTable (a, b, c)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d) => Data.MemoCombinators.Class.MemoTable (a, b, c, d)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h)
instance (Data.MemoCombinators.Class.MemoTable a, Data.MemoCombinators.Class.MemoTable b, Data.MemoCombinators.Class.MemoTable c, Data.MemoCombinators.Class.MemoTable d, Data.MemoCombinators.Class.MemoTable e, Data.MemoCombinators.Class.MemoTable f, Data.MemoCombinators.Class.MemoTable g, Data.MemoCombinators.Class.MemoTable h, Data.MemoCombinators.Class.MemoTable i) => Data.MemoCombinators.Class.MemoTable (a, b, c, d, e, f, g, h, i)
instance Data.MemoCombinators.Class.MemoTable ()
instance Data.MemoCombinators.Class.MemoTable GHC.Types.Word
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Word.Word16
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Word.Word32
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Word.Word64
instance Data.MemoCombinators.Class.MemoTable GHC.Internal.Word.Word8
instance Data.MemoCombinators.Class.MemoTable a => Data.MemoCombinators.Class.Memoizable (a -> b)
