
On 10/07/15 04:34, Ben Gunton wrote:
When a module is imported, or used for the first time, are there things that are not fully evaluated?
Evaluation isn't tied to modules in any way. Modules are namespaces; they are strictly compile-time entities. Imagine that in your module you define at the top level fac10 :: Integer fac10 = product [1..10] This is known as CAF, a constant applicative form. If you never demand the value of fac10 in your program, it will never get evaluated. If you do demand the value of fac10, it will be evaluated the first time, and then fac10 will be modified to point to the actual value instead of a thunk, so all the subsequent calls will be much faster. Now, I suspect that there may be something like fac10 in Data.Fixed or perhaps one of its dependencies. It doesn't even have to be defined in the code: during optimization, a lot of things become CAFs when ghc finds something that looks like a constant and floats it out to the top level. Roman