On Tue, 9 Jun 1998, Mariano Suarez Alvarez wrote:

> In a typed language, a function *cannot* be applied to something outside
> its domain. That's the whole point!

That represents a certain degree of idealisation though? E.g., sqrt _as a
(single valued) mathematical function_ has domain R^{>=0}. Certainly I
could define a constructed datatype which is exactly this set. But if I
want to use machine floats the natural type is Float->Float. Type classes
don't appear to help because a condition for type (i.e., set) membership
like (>=0) can't in general be decided at compile time. So I seem to be
faced with the fact that my argument type is a superset of the domain, and
I have to either check at run time or prove that only elements of the
domain will ever actually turn up.

Types catch lots of errors, but by no means all of them. (Presumably
similar examples can occur by, e.g., defining size balanced trees as Tr a
= Nd a (Tr a) (Tr a) | Lf which doesn't guarantee that a type-checking
expression is necessarily size-balanced.)

Or am I missing a terribly obvious point? 

cheers, dave
------------------------------------------------------------------------
email: [EMAIL PROTECTED]       "Taught the wife some html. __Bad
www.cs.bris.ac.uk/~tweed/pi.htm   move__." -- Alan Cox
work tel: not available          


Reply via email to