[Haskell-cafe] Template Haskell -- when are things evaluated?
Emil Axelsson
emax at cs.chalmers.se
Thu Mar 13 04:00:30 EDT 2008
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
More information about the Haskell-Cafe
mailing list