El 18/06/15 a les 17:05, Ziv Scully ha escrit:
A more direct translation is the following, which is a
little more clunky than but has the exact same structure as the original.
fun mymodule items = <xml>
<h3>title</h3>
{if null items
then <p>Sorry, no items left</p>
else <xml>
<ul>
{List.mapX (fn item =>
<xml><li><b>{[item]}</b><</li></xml>)}
</ul>
</xml>}
</xml>
At the moment, the only place to learn about List.mapX and friends is by
looking through the .urs files in lib/ur, though the types of most of
the functions make clear what they do.
Ok. with a little bit of debug.
Being
fun null [t] (li: list t) =
case li of
[] => True
| _ => False
(* --- without hamlet --- *)
fun mymodule items = <xml>
<h3>title</h3>
<div>
{if null items
then <xml><p>Sorry, no items left</p></xml>
else <xml>
<ul>
{List.mapX (fn item =>
<xml><li><b>{[item]}</b></li></xml>) items}
</ul>
</xml>}
</div>
</xml>
(* --- with hamlet like style --- *)
fun mymodule items = <ixml>
<h3> title
<div>
$if {null items}
<p> Sorry, no items left
$else
<ul>
$forall {item} <- {items}
<li> <b>{[item]}</b>
</ixml>
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur