h&8      !"#$%&'()*+,-./01234567 Safe-Inferredmemoize"A memoization class. An instance  T for some type T means that that . method can memoize for parameters of type T. Safe-Inferredmemoize To derive  instances for the given data types. In the simplest usage, to derive " for an algebraic datatype named T, write:  deriveMemoizable ''T -This assumes that all the type parameters of T0 that are not annotated with a kind other than * should be listed as requiring  instances in the instance context. For example, given a data type declared as ! data T a (b :: * -> *) c = ... %the generated instance will look like  instance ( a,  c) =>  (T a b c) where ... 0For more precise control over the context, use . N.B.: The TemplateHaskell: language extension must be enabled to use this function.memoizeLike 2 but takes a second argument, which is a list of 8s to specify which type parameters of the type should be mentioned in the context. For example, given the same definition for T as above, we can write " deriveMemoizableParams ''T [3]  to leave the first parameter of T out of the context and show only the third, yielding the instance  instance  c =>  (T a b c) where ...  N.B.: The TemplateHaskell: language extension must be enabled to use this function.memoizeIn cases where neither  nor  can figure out the right context for an instance declaration, one can declare the instance manually and use this function to derive the method body for ). For example, suppose that a data type T is defined as:  data T a b = T (a -> Bool) b For T a b to be memoizable,  a -> Bool) must be, and based on the instance for (->), this means that a must satisfy 9 and :, so ) cannot build the right context for the # instance. Instead, one can write:  instance (; a, : a, 9 a,  b) => 2 (T a b) where memoize = $(deriveMemoize ''T) <memoizeThe main entry point delegates to check given type name, renames type parameters, and generates the instance.=memoizeGiven the type name for the requested instance, checks if it corresponds to a data or newtype, and if so, returns the name, a list of its parameters, and a list of constructor names with their arities.>memoizeGiven a list, produces a list of nicely printable, distinct names. Used so that instances print with nice parameters names, like ' instance Memoizable (T a b c) where  instead of 5 instance Memoizable (T a[1] b[2] c32424534) where ?memoizeBuild the type class instance context, give the necessary information to select which parameters to include. If the first argument is Just ixs, then there should be  instances for exactly those parameters, by index, in the context. Otherwise, choose the parameters that have no explicit kind from the list of binders. The third argument gives the actual type variable names to use.@memoize Build the  instance head for the given type name and parameter type variables.Amemoize Build the  method. The form of  is always  memoize f = lookup where cache1 = memoize $ x1 -> ... memoize $ x(a1) -> f (C1 x1 ...) ... cacheN = memoize $ x1 -> ... memoize $ x(aN) -> f (CN x1 ...) lookup (C1 x1 ...) = cache1 x1 ... ... lookup (CN xN ...) = cacheN xN ... where C1 ... CN, are the constructors of the data type and aj is the arity of constructor Cj.:In this method, we allocate fresh names for the parameter f , the lookup function, and the N8 caches. We then delegate to build the definitions of look and the caches.BmemoizeBuild the body of the , method, as described in the comment above ACmemoizeBuild the look function by building a clause for each constructor of the datatype.DmemoizeBuild a lookup clause for one constructor. We lookup a value by matching that constructor and then passing its parameters to the cache for that constructor.EmemoizeBuild the definition of a cache for the given constructor. We do this by binding the cache name to a cascading sequence of memoizations for each component in the constructor's arity.FmemoizeGiven the remaining arity to memoize, the name of the function to memoize, and the accumulated parameter so far, build the memoization chain. Safe-Inferred8WmemoizeMemoize a two argument functionmemoize!Memoize a three argument functionmemoize Memoize a four argument functionmemoize Memoize a five argument function memoizeMemoize a six argument function memoize!Memoize a seven argument function memoize?@ABCABD>EFGHIJKLMNOPQARSATUVABWABXABYABZAB[AB\>?]$memoize-1.1.2-KuXBdoJ9pxQBBT3wn8wOIUData.Function.MemoizeData.Function.Memoize.ClassData.Function.Memoize.TH Data.Functionfix MemoizablememoizederiveMemoizablederiveMemoizableParams deriveMemoizememoize2memoize3memoize4memoize5memoize6memoize7memoFixmemoFix2memoFix3memoFix4memoFix5memoFix6memoFix7 traceMemoize memoizeFinite$fMemoizableWord64$fMemoizableWord32$fMemoizableWord16$fMemoizableWord8$fMemoizableWord$fMemoizableChar$fMemoizableInt$fMemoizableFinite $fEqFinite$fBoundedFinite $fEnumFinite$fFunctorBinaryTreeCache$fMemoizable()$fMemoizableBool$fMemoizableOrdering$fMemoizableMaybe$fMemoizableEither$fMemoizable[]$fMemoizableComplex$fMemoizableVersion$fMemoizableSolo$fMemoizable(,)$fMemoizable(,,)$fMemoizable(,,,)$fMemoizable(,,,,)$fMemoizable(,,,,,)$fMemoizable(,,,,,,)$fMemoizable(,,,,,,,)$fMemoizable(,,,,,,,,)$fMemoizable(,,,,,,,,,)$fMemoizable(,,,,,,,,,,)$fMemoizableRatio$fMemoizableVoid$fMemoizableFUN$fMemoizableInteger$fMemoizable(,,,,,,,,,,,)ghc-prim GHC.TypesIntbaseGHC.EnumBoundedEnum GHC.ClassesEqderiveMemoizable' checkName freshNames buildContext buildHeadbuildMethodDecbuildMethodExp buildLookupbuildLookupMatch buildCache composeMemosGHC.ShowShow Debug.Tracetrace theFinitesminBoundmaxBoundtoEnumfromEnumsuccpredChar