Dear Haskell implementors,
What do you think of improving the error messages like
Prelude.head: empty list
(for say, head [] :: (Int,Char) )
Prelude.take: negative argument
(for say, take (-1) [(0,'b'),(1,'a')] )
?
As many people had said, such messages are not very helpful.
Because head [] may occur in million places in the program.
For example, my recent DoCon program, written in Haskell, reports the
messages like
suchAndSuch_take n [a1..]
a1 = x/(x+1) <- Fraction (UPol Integer)
n = -2
Negative n
It gives much more definite info on where and how the bad `take'
occurred. It prints some part of the argument values and their short
domain description (imagine it is Type expression).
The domain description is helpful too. For example, the above output
"x+1" could mean rational coefficients, or maybe, x to be something
different from polynomial variable - all these data may look the same
after applying `shows'.
And `<- Fraction (UPol Integer)', it resolves such ambiguity.
Probably, similar approach would make possible for Haskell to report
the errors like
` Prelude.head [] :: (Int,Char) '
` Prelude.take n [(0,'b')...] :: [(Int,Char)]
n = -1
Negative n
'
One needs (1) to print some part of values
(2) to print some type expressions
(1) looks easy.
(2) - I do not know what info on the types is possible at the
run-time. The implementors should know.
My Haskell application, it defines the showsDomOf operation
of class Set. This operation displays the domain (type) of its
argument, and is defined naturally according to the type
constructors. For example:
instance (Set a, Set b) => Set (a,b)
where
showsDomOf (a,b) =
knowing how to display domain(a), domain(b),
form
('(':).showsDomOf a .(',':).showsDomOf b .(')':)
Regards.
------------------
Sergey Mechveliani
[EMAIL PROTECTED]