[Haskell] Repeated evaluation of a constant value.

Paul Johnson paul at cogito.org.uk
Tue Sep 26 13:06:27 EDT 2006


Lemmih wrote:
>
> Change:
>
>>  > table :: [(String, Integer)] -> String -> Maybe Integer
>>  > table ls str = Map.lookup str fm
>>  >    where fm = trace "Trace: making the map" $ Map.fromList ls
>
> to:
>
>>  > table :: [(String, Integer)] -> String -> Maybe Integer
>>  > table ls = \str -> Map.lookup str fm
>>  >    where fm = trace "Trace: making the map" $ Map.fromList ls
This did the trick, in both this toy example and in the more complicated 
real program.  It turns out that the seq later on is not actually necessary.

Thanks,

Paul.


More information about the Haskell mailing list