[Haskell-cafe] memorize function with number parameterized types in GHC

Bin Jin bjin1990 at gmail.com
Mon Nov 7 06:54:39 CET 2011


The actual time to calculate p2num and montgKeys are both O(log P). What
I'm looking is a constant time lookup.
On Nov 7, 2011 1:51 PM, "Yucheng Zhang" <yczhang89 at gmail.com> wrote:

> On Mon, Nov 7, 2011 at 9:29 AM, Bin Jin <bjin1990 at gmail.com> wrote:
> > Hi
> > This method is what I'm looking for. it's a nice general solution, but it
> > doesn't solve my problem here.
> > I'm using ghc 7.0.3, I tried to cache p2num and montgKeys in the way you
> > showed. It seems that ghc doesn't memorize p2num and reject to compile
> new
> > montgKeys.
> > I think caching values with dynamic types is complicated in ghc's runtime
> > environment. Anyone knows the details?
>
> Adding memorization directly to 'montgKeys' or 'p2num' should be possible,
> if you write your own version of MemoTrie dealing with dynamic types.
>
> However, this memorization requires an O(log P) lookup in the trie.
> This lookup process will require the whole type structure of P to be
> examined, which is of size O(log P).
>
>
>
> Yucheng Zhang
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111107/ab5aeb43/attachment-0001.htm>


More information about the Haskell-Cafe mailing list