haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] does the order of splice definitions matter in templa

Subject: Re: [Haskell-cafe] does the order of splice definitions matter in template haskell, or is this a bug?
From: Ian Lynagh
Date: Wed, 31 Oct 2007 19:43:01 +0000
Hi Thomas,

On Wed, Oct 31, 2007 at 03:27:20PM -0400, Thomas Hartman wrote:
> I have a situation where
> 
> ... stuff...
> 
> $(expose ['setState, 'getState]
> f = SetState
> 
> compiles but
> 
> f = SetState
> $(expose ['setState, 'getState]
> 
> doesn't compile, with error: Not in scope: data constructor 'SetState.
> 
> Is this a bug?

Not if SetState is created by the splice or defined after the splice,
no.

GHC typechecks up to the splice before running the splice, and then
continues typechecking everything past the splice afterwards. So if f is
defined before the splice then it must typecheck without the results of
the splice (or anything later in the file).


Thanks
Ian

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>