Correction:

his indented xml has been designed as a template system for the yesod web framework (http://www.yesodweb.com/).

Lets make a comparison with equivalent code:

(* --- hamlet style template *)

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>

(* ---------- without hamlet ---- *)

val emptyListSnippet = <xml>
                        <p> Sorry, no items left</p>
                       </xml>

fun listItemSnippet item = <xml>
                      <li> <b>{[item]}</b> </li>
                    </xml>

fun listSnippet items =
   List.foldr join <xml/> <|
        List.map listItemSnippet items

fun mymodule items =
<xml>
   <h3>title</h3>
   <div>   { if null
                  then emptyListSnippet
                  else <xml>
                          <ul>
                              {listSnippet items}
                          </ul>
                       </xml>
           }
    </div>
</xml>


_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to