packages feed

runmemo-1.0.0.1: runmemo.cabal

name:                runmemo
version:             1.0.0.1
synopsis:            A simple memoization helper library

description:
  This library encourages you to do memoization
  in three separate steps:
  .
  (1) Create a memoizable function
  .
  (2) Create or select an appropriate memoizer
  .
  (3) Run the memoizer on the memoizable function
  .
  Let's start with the first.
  When you create a memoizable function,
  you should use the @self@ convention,
  which is that the first input to the function is @self@,
  and all recursive calls are replaced with @self@.
  One common convention that goes well with the @self@ convention
  is using a helper function @go@, like so:
  .
  @
  fib :: Memoizable (Integer -> Integer)
  fib self = go
  \  where go 0 = 1
  \        go 1 = 1
  \        go n = self (n-1) + self (n-2)
  @
  .
  Now for the second. For this example,
  we need a Memoizer that can handle an @Integer@ input,
  and an @Integer@ output. @Data.MemoCombinators@ provides
  @integral@, which handles any @Integral@ input, and
  any output. @Data.MemoUgly@ provides @memo@,
  which can memoize any function @a -> b@, given an @Ord@ instance
  for @a@.
  .
  Third, let's run our memoizers!
  Since we have decoupled the definition of the memoized function
  from its actual memoization, we can create multiple
  memoized versions of the same function if we so desire.
  .
  @
  import qualified Data.MemoUgly as Ugly
  import qualified Data.MemoCombinators as MC
  .
  fibUgly :: Integer -> Integer
  fibUgly = runMemo Ugly.memo fib
  .
  fibMC :: Integer -> Integer
  fibMC = runMemo MC.integral fib
  @
  .
  You could easily do the same with @Data.MemoTrie.memo@,
  @Data.Function.Memoize.memoize@, etc.
  .
  Using this technique, you can create local memoized functions
  whose memo tables are garbage collected as soon as
  they are no longer needed.


homepage:            https://github.com/DanBurton/runmemo
license:             BSD3
license-file:        LICENSE
author:              Dan Burton
maintainer:          danburton.email@gmail.com
copyright:           (c) Dan Burton 2012

category:            Data
build-type:          Simple
cabal-version:       >=1.8

library
  hs-source-dirs:    src
  exposed-modules:   Data.RunMemo
  extensions:        NoImplicitPrelude
  ghc-options:       -Wall

test-suite test-race
  type:            exitcode-stdio-1.0
  hs-source-dirs:  test, src
  main-is:         test-race.hs
  build-depends:   data-memocombinators >= 0.4, base == 4.*, time >= 1.4

source-repository head
  type:     git
  location: git@github.com:DanBurton/runmemo.git

source-repository this
  type:     git
  location: git@github.com:DanBurton/runmemo.git
  tag:      runmemo-1.0.0.1