
13 Mar
2008
13 Mar
'08
4 a.m.
Hello all! Up until yesterday I thought I understood the basics of Template Haskell, but now I'm a little confused. Consider the following code module A where a1 = [| (2::Int) + 2 |] a2 = let x = (2::Int) + 2 in [| x |] a3 = [| y |] where y = (2::Int) + 2 z = (2::Int) + 2 a4 = [| z |] module B where import A a1S = $a1 a2S = $a2 a3S = $a3 a4S = $a4 I'd have thought that in all four cases the addition was evaluated at compile-time, but compiling with -ddump-splices reveals that this is only the case for a2 and a3. Is there a general reliable rule for when things are evaluated? Thanks, / Emil