"To give a sense of what programming in Boomerang is like, we will define the lens implementing the transformations between XML and CSV composers shown above.
First we define a lens c that handles a single <composer> element. It uses a number
of functions defined in our XML library, as well as primtives for copying (copy) and
deleting (del) strings, and for concatenating lenses (.).
let c : lens =
Xml.elt NL2 "composer"
begin
Xml.simple_elt NL4 "name"
(copy [A-Za-z ]+ . ins ", ") .
Xml.attr2_elt_no_kids NL4 "years"
"birth" (copy NUMBER . ins "-")
"death" (copy NUMBER) .
Xml.simple_elt NL4 "nationality" (del [A-Za-z]+)
end
Using c, we then define a lens that handles a top-level <composers> element, enclosing a list of <composers>. This lens is defined using the features already described, a primitive for inserting a string (ins), as well as union (|) and Kleene star.
let cs : lens =
Xml.elt NL0 "composers"
begin
copy EPSILON |
c . (ins newline . c)*
end
Ask HN/PG: Asterisks around something make it italics (except in indented code, apparently). In the above comment I had to remove a literal asterisk in the text because I couldn't figure out how to escape it. Backslash doesn't work, and two stars in a row doesn't work. Any ideas?
Update: Okay, so putting spaces around it ( * ) works. But the asterisk in question was inside parens without spaces.
"To give a sense of what programming in Boomerang is like, we will define the lens implementing the transformations between XML and CSV composers shown above.
First we define a lens c that handles a single <composer> element. It uses a number of functions defined in our XML library, as well as primtives for copying (copy) and deleting (del) strings, and for concatenating lenses (.).
Using c, we then define a lens that handles a top-level <composers> element, enclosing a list of <composers>. This lens is defined using the features already described, a primitive for inserting a string (ins), as well as union (|) and Kleene star. ..."