Tom Pledger <[EMAIL PROTECTED]> wrote:

> Craig Dickson writes:
>  > [...]
>  > I don't want a pattern like "(x:xs)" to match the empty list, which
>  > it presumably would if "head []" and "tail []" did not fail (x and
>  > xs would both be bound to []).
>
> I don't think it would.  Patterns involve data constructors like []
> and (:), but not functions like head and tail, which may happen to
> obey all sorts of rules, but aren't part of the data type definition.

True, but I think the standard functions, especially those in the prelude,
ought to make sense in terms of the data type's definition, for the sake of
presenting a consistent view of that data type to the programmer. If
"(x:xs)" does not match [], then the reason for this should be that [] has
no head to bind to x, nor tail to bind to xs; and if this is so, then "head
[]", "tail []", and "take 1 []" should also fail. Conversely, if "head []"
and "tail []" succeed, then "(x:xs)" should match the empty list. If this
consistency is not maintained, then the language and its core functions are
presenting a confusing and somewhat contradictory view of what a list is and
how you interact with it.

Craig


Reply via email to