[Ur] Hamlet like XML, structured by indentation with tag autoclosing

Gabriel Riba gabriel at xarxaire.com
Sat Jun 20 06:22:23 EDT 2015


El 18/06/15 a les 23:55, Ziv Scully ha escrit:
> As far as I can see, the proposed changes do 3 things:
>
> (1) Add a few new things especially for layout (the forall/foreach/etc.
> sort of thing).
> (2) Make normal XML a bit nicer by eliminating closing tags.
> (3) Make XML mixed with Ur/Web "macros" less clunky by eliminating some
> extra {} and <xml></xml> pairs.
>


* First, with structure by indentation with tag autoclosing, the 
document tree structure shows clearer.

Check https://hackage.haskell.org/package/hamlet
and 
http://www.yesodweb.com/book/shakespearean-templates#shakespearean-templates_hamlet_html

* Second, you can specify conditional subtrees, subject to decision logic

   $if cond
      subtree1

   $elsif cond
      subtree2

   $else cond
      subtree3

   ---------------

   $some pattern
      subtree1

   $none
      subtree2

   ---------------

   $case expression
     $of pattern
        subtree1

     $of pattern
        subtree2


See see 
http://www.yesodweb.com/book/shakespearean-templates#shakespearean-templates_conditionals

   --------------

* Third, you can specify foldMap traversals of foldable containers

    $foldmap {items_expr} <| fn {item_pattern} =>
       item_subtree


Haskell differentiates between sequentially enforced traversal 
(Data.Traversable) and non-enforced (Data.Foldable) as 
non-monadic/applicative code exec. order is not granted sequential.

I am not sure about this need in Ur, but in case, an extra logic 
statement could be used.
----------

Any other control structure on subtrees can be envisioned as needed.






More information about the Ur mailing list