This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Re: xpath2 functions returning ()


> > A string is a list (sequence) of characters. The empty string
> > is an empty such
> > sequence. It is "no character" but it is still a string
> > (sequence) -- the empty
> > string (sequence).
> 
> If you modeled a string as a sequence of characters, then to have a sequence
> of strings you would need to allow sequences of sequences; and then you
> would need to distinguish between an empty sequence and a sequence whose
> only member was an empty sequence. You can't get rid of the problem that
> easily!

Shouldn't be a problem, these two sequences are of different type, therefore
cannot/shouldn't be compared. No sense in comparing apples and eggs.

This is no problem in Haskell.

The type of the empty list:

MyExamples> :t []
[] :: [a]

that is, the type of the empty list is a list of any-typed values having all the
same type.

MyExamples> :t [[]]
[[]] :: [[a]]

The type of the list having a single element, which is the empty list is:
a list of lists, each of which is of (a single) any-type.

So the the type of the empty sequence is different from the type of the sequence of
sequences that has a single element (even if this single element happens to be the
empty sequence).

As can be seen from the above examples, the HUGS interpreter can automatically
determine the type of these expressions.

It seems to me that what was not the perfect decision was to allow a sequence to
have elements of different type. This is another (additional to using a single type
for sequence and set) unpleasant mix -- this time between lists and something like
tuples. In Haskell lists have undefined zero or positive number of elements of the
same type, while tuples have a pre-defined number of components each with its own
pre-defined type.

It is still unclear to me why the restriction was imposed that a sequence should not
have elements that are sequences. Take into account that every element-node that is
an element of a sequence actually represents a whole tree. Then the statement that a
sequence does not contain elements-sequences -- this statement does not seem to be
perfect -- a sequence can even contain elements that are trees.

Cheers,
Dimitre Novatchev.






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]