Re: [xsl] The Holy Trinity of Functional Programming ... Is there a way to define recursive data types in XSLT 2.0?

Subject: Re: [xsl] The Holy Trinity of Functional Programming ... Is there a way to define recursive data types in XSLT 2.0?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 22 Aug 2012 12:21:05 +0100
On 22/08/2012 10:41, Costello, Roger L. wrote:
> Hi Folks,
>
> Professor Richard Bird has written extensively on functional
> programming. In one of his books he has a fascinating discussion on
> three key aspects of functional programming, which he calls the holy
> trinity of functional programming.
>

It wasn't clear how much of your datatype definition was from the book and how much just in the mail. whether bottom and an infinite number are part of the datatype depend greatly on the framework yo are in.
Most definitions of a natural number type wouldn't include either.


Perhaps the most natural model for Nat in xslt2 would be to model
0 as () and Succ n as <Succ> n </Succ> that is the datatype Nat corresponds to the DTD


<!ELEMENT Succ (Succ?) >

or equivalent in a schema language of your choice.

That can model all the natural numbers and you could then easily define recursive functions for < + etc.

It does not model bottom except by non-terminating functions. A possible way to model that in XSLT3 draft would be to model bottom as an exception (except that determining that a function is in fact non terminating and so models bottom is a little hard (ask Turing)).

Similarly since XML documents are finite you can not model an infinite number using that technique. Of course you could add a new element <INFTY/> to model that and add some extra rules, changing the above to

<!ELEMENT Succ (INFTY|Succ)?) >
<!ELEMENT INFTY EMPTY>



David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread