[Template-haskell] "contexts differ in length" fires when usingsplices in non-recursive bindings?

Claus Reinke claus.reinke at talk21.com
Sat Jul 12 19:08:18 EDT 2008


Thanks everyone, for confirmation, simplification, and explanation.

> I think the problem is that the SCC analysis is done before the splices
> are run (which is during type checking), 

If that is the case, shouldn't the analysis results be updated with
the information emerging from splices? It still feels like a bug, 
and the symptoms can be very confusing.

>    $( [d| |] )
> between the two definitions then that forces GHC to consider them as
> separate binding groups (as it type checks the first binding, then runs
> the splice, then type checks the second one).

Thanks, that works, but is rather ugly and not very practical
(pity that staging splices in this way doesn't work around the
we-need-two-modules issue;-).

Another workaround is {-# LANGUAGE RelaxedPolyRec #-},
combined with explicit type signatures that keep the dependency
analysis happy (users guide, 8.7.7).

Claus




More information about the template-haskell mailing list