{-# OPTIONS_GHC -Wno-orphans #-}

-- |
-- Straightforward function memoization library;
-- see [Examples](https://github.com/davidspies/fastmemo/blob/master/test/Examples.hs) for example usage
module Data.Function.FastMemo (Memoizable (..), memoizeFixedLen, memo1, memo2, memo3, memo4, memo5, memo6, memo7) where

import Data.Function.FastMemo.ByteString ()
import Data.Function.FastMemo.Char ()
import Data.Function.FastMemo.Class (Memoizable (..))
import Data.Function.FastMemo.Instances ()
import Data.Function.FastMemo.Int ()
import Data.Function.FastMemo.Integer ()
import Data.Function.FastMemo.Natural ()
import Data.Function.FastMemo.Ratio ()
import Data.Function.FastMemo.Util (memoizeFixedLen)
import Data.Function.FastMemo.Vector ()
import Data.Function.FastMemo.Word ()

memo1 :: Memoizable a => (a -> b) -> a -> b
memo1 :: (a -> b) -> a -> b
memo1 = (a -> b) -> a -> b
forall a b. Memoizable a => (a -> b) -> a -> b
memoize

liftMemo :: Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo :: (b -> b) -> (a -> b) -> a -> b
liftMemo b -> b
m a -> b
f = (a -> b) -> a -> b
forall a b. Memoizable a => (a -> b) -> a -> b
memoize ((a -> b) -> a -> b) -> (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$ b -> b
m (b -> b) -> (a -> b) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f

memo2 :: (Memoizable a, Memoizable b) => (a -> b -> c) -> a -> b -> c
memo2 :: (a -> b -> c) -> a -> b -> c
memo2 = ((b -> c) -> b -> c) -> (a -> b -> c) -> a -> b -> c
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c) -> b -> c
forall a b. Memoizable a => (a -> b) -> a -> b
memo1

memo3 :: (Memoizable a, Memoizable b, Memoizable c) => (a -> b -> c -> d) -> a -> b -> c -> d
memo3 :: (a -> b -> c -> d) -> a -> b -> c -> d
memo3 = ((b -> c -> d) -> b -> c -> d)
-> (a -> b -> c -> d) -> a -> b -> c -> d
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c -> d) -> b -> c -> d
forall a b c.
(Memoizable a, Memoizable b) =>
(a -> b -> c) -> a -> b -> c
memo2

memo4 :: (Memoizable a, Memoizable b, Memoizable c, Memoizable d) => (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
memo4 :: (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
memo4 = ((b -> c -> d -> e) -> b -> c -> d -> e)
-> (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c -> d -> e) -> b -> c -> d -> e
forall a b c d.
(Memoizable a, Memoizable b, Memoizable c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
memo3

memo5 :: (Memoizable a, Memoizable b, Memoizable c, Memoizable d, Memoizable e) => (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
memo5 :: (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
memo5 = ((b -> c -> d -> e -> f) -> b -> c -> d -> e -> f)
-> (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c -> d -> e -> f) -> b -> c -> d -> e -> f
forall a b c d e.
(Memoizable a, Memoizable b, Memoizable c, Memoizable d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
memo4

memo6 :: (Memoizable a, Memoizable b, Memoizable c, Memoizable d, Memoizable e, Memoizable f) => (a -> b -> c -> d -> e -> f -> g) -> a -> b -> c -> d -> e -> f -> g
memo6 :: (a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
memo6 = ((b -> c -> d -> e -> f -> g) -> b -> c -> d -> e -> f -> g)
-> (a -> b -> c -> d -> e -> f -> g)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c -> d -> e -> f -> g) -> b -> c -> d -> e -> f -> g
forall a b c d e f.
(Memoizable a, Memoizable b, Memoizable c, Memoizable d,
 Memoizable e) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
memo5

memo7 :: (Memoizable a, Memoizable b, Memoizable c, Memoizable d, Memoizable e, Memoizable f, Memoizable g) => (a -> b -> c -> d -> e -> f -> g -> h) -> a -> b -> c -> d -> e -> f -> g -> h
memo7 :: (a -> b -> c -> d -> e -> f -> g -> h)
-> a -> b -> c -> d -> e -> f -> g -> h
memo7 = ((b -> c -> d -> e -> f -> g -> h)
 -> b -> c -> d -> e -> f -> g -> h)
-> (a -> b -> c -> d -> e -> f -> g -> h)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
forall a b. Memoizable a => (b -> b) -> (a -> b) -> a -> b
liftMemo (b -> c -> d -> e -> f -> g -> h)
-> b -> c -> d -> e -> f -> g -> h
forall a b c d e f g.
(Memoizable a, Memoizable b, Memoizable c, Memoizable d,
 Memoizable e, Memoizable f) =>
(a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
memo6