darcs hsx patch, add EmbedAsAttr instance for (Attr a (XMLGenT m v))

24 views
Skip to first unread message

Jeremy Shaw

unread,
May 24, 2010, 2:18:35 PM5/24/10
to haskell-se...@googlegroups.com
Hello,

Sometimes it would be nice to write code like this:

page =
...
<a href=fooURL>foo</a>

fooURL = XMLGenT m String
fooURL = return "http://example.org/foo"


Where the attribute value is in the XMLGenT monad. (This is very
useful when using web-routes).

But, we can't because there is no suitable instance. This patch adds
an instance,

> instance (EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr
m (Attr a (XMLGenT m1 v))

(Thanks goes to Sergey Mironov for figuring this out).

- jeremy

hsx-embedasattr-for-XMLGenT-attr-values.dpath

Thomas Hartman

unread,
May 24, 2010, 3:21:13 PM5/24/10
to haskell-se...@googlegroups.com
nice!

>  fooURL = XMLGenT m String

I assume :: was meant instead of =
> --
> 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.
>
>
>



--
Need somewhere to put your code? http://patch-tag.com
Want to build a webapp? http://happstack.com

--
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.

Niklas Broberg

unread,
May 24, 2010, 4:07:56 PM5/24/10
to haskell-se...@googlegroups.com
> But, we can't because there is no suitable instance. This patch adds an
> instance,
>
>> instance (EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr
>> a (XMLGenT m1 v))

I thought this instance was already included, it's a clear oversight
that it isn't. Patch applied, thanks!

Cheers,

/Niklas

Jeremy Shaw

unread,
May 24, 2010, 4:16:58 PM5/24/10
to haskell-se...@googlegroups.com
Sweet!

You have a similar feeling instance,

instance (XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m (XMLGenT m a)
where
asAttr ma = ma >>= asAttr

But that is not quite the same. But is close enough to perhaps may you
think you covered this issue :)

- jeremy

Niklas Broberg

unread,
May 24, 2010, 4:18:53 PM5/24/10
to haskell-se...@googlegroups.com
> You have a similar feeling instance,
>
> instance (XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m (XMLGenT m a) where
>  asAttr ma = ma >>= asAttr
>
> But that is not quite the same. But is close enough to perhaps may you think
> you covered this issue :)

I think you're spot on. :)

/Niklas

--
You received this message because you are subscribed to the Google Groups "Haskell Server Pages" group.
Reply all
Reply to author
Forward
0 new messages