[Ur] Attempting to do Exercise 7.3 of Gian Perrone's UrWeb (blog) tutorial - trying to a logout() function and link to it - getting compiler errors

Adam Chlipala adamc at csail.mit.edu
Wed Jan 28 20:31:25 EST 2015


On 01/28/2015 05:38 PM, Stefan Scott Alexander wrote:
> On a related note:
>
> Is it even considered "good practice" to take a function which returns 
> a page, and attempt to modify it by (first "unrwapping" it and then) 
> appending another fragment of xml to it (and then "rewrapping" it into 
> a [transaction page] again)?

No, there is no precedent to make that design style idiomatic.  Of 
course, there isn't so much Ur/Web code in the world now, so there isn't 
much precedent, period!

I do think there's something fishy even about the original program 
you're building on, so you should probably be evaluating the whole 
approach from first principles.

> For example, given a page [pg], it tries to output another page made 
> up of: an empty <head/> tag, with the "unwrapped" [pg] appended to it.
>
> What if [pg] itself had a head tag?
>
> I remember some framework I was studying was "smart" enough, when 
> joining <xml> fragments, to "merge" all the the content of their 
> <head> tags into a *single* <head> tag - but I can't remember if that 
> framework was UrWeb (maybe it was Yesod? :-).

Ur/Web doesn't do any HTML merging of that kind.

P.S.: I don't think it's helpful to keep mentioning the notion of 
"unwrapped" in contexts like this.  To me it comes across like a Java 
programmer making a big deal out of the fact that a particular variable 
is used as an operand to the "plus" operator. 
Typed-functional-programming types think of that kind of plumbing as too 
obvious to call for explicit mention.



More information about the Ur mailing list