Yes, but I think it's not a funtion since the function didn't use the parameter. So maybe there is a way to make memorizing possible.

Also p2num is a general function used in number parameterized types, so I asked this question here.

On Nov 6, 2011 11:41 PM, "Brandon Allbery" <allbery.b@gmail.com> wrote:
On Sun, Nov 6, 2011 at 10:31, Bin Jin <bjin1990@gmail.com> wrote:

Then how about p2num, how to memorize this function.

Also I think it's okay to memorize this kind of function. The type system ensure all calling of montgKeys have the same type, e.g., it's a pure function without parameter, it's safe to memorize it since it didn't occupy more memory than representing dynamic generated types.

Did you read the wiki page you were pointed to?  ghc never memoizes functions by itself; the page provides pointers to a number of ways that you can add memoization, along with pointers to discussion of why there is no automated memoization.

http://haskell.org/haskellwiki/Memoization

--
brandon s allbery                                      allbery.b@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms