Commit facad96d authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-07-27 14:14:29 by cvscast] Empty log message

Original author: cvscast
Date: 2003-07-27 14:15:49+00:00
parent 565d5231
......@@ -2,9 +2,8 @@ Installation Notes for CDuce
============================
CDuce is written in the OCaml programming language. It has been
successfully compiled under Intel Linux, SunOS 5.7, Windows XP
and FreeBSD 4.7.
successfully compiled under Intel Linux, Mac OSX, SunOS 5.7, FreeBSD 4.7.
and Windows XP.
(See INSTALL.WIN32 for installation under Windows)
------------------------------------------------------------------------------
......
type Person = FPerson | MPerson
type FPerson = <person gender = "F">[ Name Children ]
type MPerson = <person gender = "M">[ Name Children ]
type Children = <children>[Person*]
type Name = <name>[ PCDATA ]
type Man = <man name=String>[ Sons Daughters ]
type Woman = <woman name=String>[ Sons Daughters ]
type Sons = <sons>[ Man* ]
type Daughters = <daughters>[ Woman* ]
type Citizen = FCitizen | MCitizen
type FCitizen = <person gender = "F" nat = String>[ Name Children ]
type MCitizen = <person gender = "M" nat = String>[ Name Children ]
(* note that the Children are still persons so no nationality is
recorded. Imagine now that we want to specialize the behavior of split. As it is
split works also with Citizens but it completely loose the information about
nationality. To make things harder imagine that instead split has to register
the nationality in the result type and propagate it to children as well, that
is. *)
type CMan = <man name=String nat=String>[ <sons>[CMan*] <daughters>[CWoman*] ]
type CWoman = <woman name=String nat=String>[ <sons>[CMan*] <daughters>[CWoman*] ]
let split (MPerson -> Man ; FPerson -> Woman ; FCitizen -> CWoman ; MCitizen -> CMan)
| <person gender=g nat=nn>[ <name>n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with "F" -> `woman | "M" -> `man in
let s = map mc with <person (atr)> elms -> split <person (atr+{nat=nn})> elms in
let d = map fc with <person (atr)> elms -> split <person (atr+{nat=nn})> elms in
<(tag) name=n nat=nn>[ <sons>s <daughters>d ]
| <person gender=g>[ <name>n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with "F" -> `woman | "M" -> `man in
let s = map mc with x -> split x in
let d = map fc with x -> split x in
<(tag) name=n>[ <sons>s <daughters>d ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment