However, I notice that the errors pertain to the use of TypeCast.
Possibly, hopefully, removing that hack and moving to equality
constraints proper might make it work again. No promises as to when I
can sit down and think about it though.
Cheers,
/Niklas
> --
> You received this message because you are subscribed to the Google Groups "Haskell Server Pages" group.
> To post to this group, send email to haskell-se...@googlegroups.com.
> To unsubscribe from this group, send email to haskell-server-p...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/haskell-server-pages?hl=en.
>
>
- jeremy
This instance fails:
instance (Monad m) => EmbedAsChild (HSPT' m) (Block t) where
asChild b = asChild $
<script type="text/javascript">
<% show b %>
</script>
But only when this instance is present:
instance EmbedAsChild (HSPT' m) (XMLGenT HJScript' ()) where
asChild script = asChild . snd $ evalHJScript script
because we also have this instance:
instance (EmbedAsChild m c, m1 ~ m) => EmbedAsChild m (XMLGenT m1 c) where
asChild m = asChild =<< m
So, we have two different ways to embed an XMLGenT inside of m, and
the compiler can't figure out which to use. I am not sure if this is
because it shouldn't have worked in the first place, or because of a
bug in the new type checker, or an intentional change in the way
things work...
- jeremy
So I guess this is the real meat of the problem. We have two different
XML generator monad transformers, HSPT' and HJScript'. The second
instance says that generated inner elements should be in the same
generator as the outer element in which it is embedded. The first
instance tries to embed one type of generator inside another.
When implementing this, I believed that the default (second) instance
would only be applicable if the first one "failed", being less
specific, but reading SPJ [1] I can see that this was a somewhat naive
assumption (even though it's actually worked for a long time!). I
haven't entirely been able to convince myself that the situation SPJ
talks about (Jeremy's minimized bug report) is actually the same as
the one we're discussing here, but it seems to be similar enough...
At any rate, if we can't find a way to solve this using flags or
whathaveyou, it seems to me that we still should be able to salvage
the situation by removing the first instance above, replacing it with
some explicit application of some combinator that the programmer has
to call, that runs the HJScript and returns a block that can then be
embedded normally.
Btw, Jeremy, the reason for introducing XMLGenT in the first place is
exactly the second instance above. Without that transformer there
would be no way at all to create a reasonable defaulting instance,
which would mean that all nested tags would have to be explicitly
typed everywhere - not feasible!
Cheers,
/Niklas
[1]http://hackage.haskell.org/trac/ghc/ticket/4485#comment:2
Yes, exactly. I propose we instead introduce a combinator like (naming
suggestions welcome)
script :: HJScript () -> Block ()
script = snd . evalHJScript
With the instance 'EmbedAsChild (HSPT' m) (Block t)', we could then
embed HJScript () values inside HSPT by e.g.
foo = <div><% script s %></div>
instead of just saying s in the code brackets.
Cheers,
/Niklas