[Haskell-cafe] Do I have this right? "Remembering" Memoization!

Derek Elkins derek.a.elkins at gmail.com
Tue Sep 15 17:59:19 EDT 2009


> But pedantically even the function:
>
>> quux :: Int -> Int
>> quux x = trace "Quux" (bar 12)
>
>> optmain :: IO ()
>> optmain = quux 10 `seq` quux 11 `seq` return ()
>
> might print only once if GHC at the optimization level selected recognizes
> that quux doesn't depend on its argument and rewrote your code with more
> sharing.

Well to be specific, it depends on how you define "function",

quux :: Int -> Int
quux = trace "Quux" bar

will print "Quux" once under the naive semantics.


More information about the Haskell-Cafe mailing list