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

Gabriel Riba gabriel at xarxaire.com
Thu Jun 18 14:34:48 EDT 2015


El 18/06/15 a les 19:55, Gabriel Riba ha escrit:
> El 18/06/15 a les 18:29, Adam Chlipala ha escrit:
>> On 06/18/2015 12:09 PM, Gabriel Riba wrote:
>>> (* --- 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>
>>
>> The special syntax for 'forall' bothers me a bit.  I prefer to see
>> standard function-call syntax there.  There are other iteration styles
>> that are often useful but that won't fit with the 'forall' syntax.  One
>> example is a fold-style traversal maintaining some other accumulator.
>
> Maybe:
>                $foldmap {items} <| {item}
>                   <li> <b>{[item]}</b>
>
> In Haskell:
>                 (flip foldMap) container $ \arg ->
>                     xml

A more explicitly standard form would be

                 $foldmap {items} <| fn {item} =>
                       xml

Since xml is a Monoid (has a neutral element and an append function), it 
fits in the haskell's foldMap definition:

https://downloads.haskell.org/~ghc/latest/docs/html/libraries/Data-Foldable.html#v:foldMap 






More information about the Ur mailing list