| 6 |
<title>CDuce demo</title> |
<title>CDuce demo</title> |
| 7 |
|
|
| 8 |
<box title="Types, pattern matching" link="typpm"> |
<box title="Types, pattern matching" link="typpm"> |
| 9 |
<demo label="1"><include-verbatim file="funxml_types.cd"/><![CDATA[ |
<demo><include-verbatim file="funxml_types.cd"/><![CDATA[ |
| 10 |
let title(Book -> String) <book>[ <title>x _* ] -> x |
let title(Book -> String) <book>[ <title>x _* ] -> x |
| 11 |
let authors(Book -> [Author+]) <_>[ (x::Author|_)* ] -> x |
let authors(Book -> [Author+]) <_>[ (x::Author|_)* ] -> x |
| 12 |
]]> |
]]></demo></box> |
|
</demo> |
|
|
</box> |
|
| 13 |
|
|
| 14 |
<box title="Printing functions" link="printfun"> |
<box title="Sample values" link="samp"><demo prefix="last"><![CDATA[ |
| 15 |
<demo prefix="1"><![CDATA[ |
let b1 : Book = <book>[ |
| 16 |
|
<title>[ 'Object-Oriented Programming' ] |
| 17 |
|
<subtitle>[ 'A Unified Foundation' ] |
| 18 |
|
<author>[ 'Castagna' ] ] |
| 19 |
|
let b2 : Book = <book>[ |
| 20 |
|
<title>[ 'Persistent Object Systems' ] |
| 21 |
|
<author>[ 'Atkinson' ] |
| 22 |
|
<author>[ 'Benzaken' ] |
| 23 |
|
<author>[ 'Maier' ] ] |
| 24 |
|
let v : Bib = [ b1 b2 ] |
| 25 |
|
]]></demo></box> |
| 26 |
|
|
| 27 |
|
<box title="Printing functions" link="printfun"><demo prefix="last"><![CDATA[ |
| 28 |
type FBook = Book -> String |
type FBook = Book -> String |
| 29 |
type ABook = <book print=FBook>[ Title Subtitle? Author+ ] |
type ABook = <book print=FBook>[ Title Subtitle? Author+ ] |
| 30 |
type ABib = [ ABook* ] |
type ABib = [ ABook* ] |
| 37 |
[ <book>[ <title>"T" <subtitle>"S" <author>"A" ] ] |
[ <book>[ <title>"T" <subtitle>"S" <author>"A" ] ] |
| 38 |
|
|
| 39 |
let ab = prepare b |
let ab = prepare b |
| 40 |
]]> |
]]></demo></box> |
|
</demo> |
|
|
|
|
|
</box> |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
<!-- |
<!-- |
| 44 |
#silent |
#silent |
| 45 |
let b1 : Book = <book>[ |
|
|
<title>[ 'Object-Oriented Programming' ] |
|
|
<subtitle>[ 'A Unified Foundation' ] |
|
|
<author>[ 'Castagna' ] ] |
|
|
let b2 : Book = <book>[ |
|
|
<title>[ 'Persistent Object Systems' ] |
|
|
<author>[ 'Atkinson' ] |
|
|
<author>[ 'Benzaken' ] |
|
|
<author>[ 'Maier' ] ] |
|
|
let v : Bib = [ b1 b2 ] |
|
| 46 |
#verbose |
#verbose |
| 47 |
|
|
| 48 |
let z = authors b1 |
let z = authors b1 |