| 1 |
abate |
41 |
type Person = FPerson | MPerson;; |
| 2 |
|
|
type FPerson = <person gender='F'>[Name Children ];; |
| 3 |
|
|
type MPerson = <person gender='M'>[ Name Children];; |
| 4 |
|
|
type Children = <children>[Person*];; |
| 5 |
|
|
type Name = <name>[String];; |
| 6 |
abate |
34 |
|
| 7 |
|
|
type Man = <man>[ Name Sons Daughters ];; |
| 8 |
|
|
type Woman = <woman>[ Name Sons Daughters ];; |
| 9 |
|
|
type Sons = <sons>[ Man* ];; |
| 10 |
|
|
type Daughters = <daughters>[ Woman* ];; |
| 11 |
|
|
|
| 12 |
abate |
35 |
let fun sort (MPerson -> Man ; FPerson -> Woman) |
| 13 |
|
|
<person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] -> |
| 14 |
abate |
40 |
let tag = match g with 'F' -> `woman | 'M' -> `man in |
| 15 |
abate |
36 |
let s = map mc with (x & MPerson) -> sort x in |
| 16 |
abate |
35 |
let d = map fc with x -> sort x in |
| 17 |
abate |
36 |
<(tag)>[ n <sons>s <daughters>d ] |
| 18 |
abate |
41 |
in sort(<person gender='F'>[ <name>["pippo"] <children>[ ]]);; |
| 19 |
abate |
37 |
|