On 30-Mar-2000, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:
> | What do you think of improving the error messages like
> |   Prelude.take:  negative argument
> |                              (for say,  take (-1) [(0,'b'),(1,'a')] )
> 
> That would be splendid.  But I don't see how to do it.
> 
>       take :: Int -> [a] -> [a]
> 
> Since take is polymorphic in a, I can't print a member of the
> list.  If you want to define your own take
> 
>       mytake :: Show a => Int -> [a] -> [a]
> 
> that's fine, but it's a different function.

Well, there's two separate issues here.

One issue is what exception is thrown.  One this issue, you are absolutely
right: there is no way for the exception thrown to expose any information
about the value or type of the argument, without breaking some of the nice
properties that Haskell possesses.

The other issue is what error message the implementation prints out if such an
exception is not caught (as is _always_ the case for implementations which
don't support ghc's `Exception' module or something equivalent).
And on this issue, Haskell semantics don't impose any constraints.
The message that the implementation prints out can be as informative
as the implementor is capable of.

There is no conceptual difficulty with a Haskell implemention printing out a
full stack trace, complete with the values of all of the arguments.  Of
course, modifying an existing implementation to do so may well be by no means
trivial, but it's just a matter of programming...
If you really don't see how it could be done, I'd be happy to sketch
the outline of a possible implementation.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to