Why doesn't the implementation simply tack on a line number to the error
message? One easy way to do this is to give an address/offset to where the
error occurred, and then recompile the module to find the line number. This
is a fairly common strategy among traditional compilers, especially Bor
People have written:
| Or you can do what hbc has done for donkey's years
| and include 'showType' in Show.
:
| Incidentally, nhc98 also has had 'showType' in class
| Show since the year dot - only Hugs and ghc lack it.
| (Does anyone know why this idea didn't make it into
| Haskell'98?)
Malcolm Wallace wrote:
>
> > > class ShowType a where
> > > showType :: a -> String
> >
> > Or you can do what hbc has done for donkey's years and
> > include 'showType' in Show.
>
> Incidentally, nhc98 also has had 'showType' in class Show since the
> year dot - only Hugs and ghc la
> > class ShowType a where
> > showType :: a -> String
>
> Or you can do what hbc has done for donkey's years and
> include 'showType' in Show.
Incidentally, nhc98 also has had 'showType' in class Show since the
year dot - only Hugs and ghc lack it. (Does anyone know why this
idea d
[EMAIL PROTECTED] writes:
>
...
>
> Although you can't show the value (because there isn't one), you can
> at least show the type of the expression:
>
> class ShowType a where
> showType :: a -> String
Or you can do what hbc has done for donkey's years and
include 'showType'
> instance ShowType a => ShowType [a]
>where
>showsType xs = ('[':) . showsType x . (']':) where ~(x:_) = xs
>
> Looks like ~(x:_) gives access to a constant instance operation
> on the type of an element of xs even when xs is empty.
>
> Looks like it works. But I do not understan
Malcom and Sergey write:
> instance ShowType a => ShowType [a]
> where
> showsType xs = ('[':) . showsType x . (']':) where ~(x:_) = xs
Perhaps
where [x] = [error "not used"] `asTypeOf` xs
gives the idea better.
--KW 8-)
--
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) --
| To: Simon Peyton-Jones
| Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
| Subject: Re: improving error messages
|
|
| On 30-Mar-2000, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:
| > | What do you think of improving the error messages like
| > | Prelu
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.
>
>
Malcolm Wallace <[EMAIL PROTECTED]> writes
>> And for (head []) there's really no useful info to hand. So I'm stumped.
> Although you can't show the value (because there isn't one), you can
> at least show the type of the expression:
Printing the type is very desirable in this situation.
But
On Fri, 31 Mar 2000, S.J.Thompson wrote:
> To help students I have compiled a list of messages and examples of code that
> provoke them. In many cases a little effort would, I guess, lead to vastly
> more informative error messages. I'd be interested to hear what you (and the
> Hugs gro
To my suggestion on the error messages
Ketil Malde <[EMAIL PROTECTED]> writes
> [..]
> e.g instead of Hugs' Prelude head:
>
>head :: [a] -> a
>head (x:_)= x
>
> we can use:
>
>head :: [a] -> a
>head [] = error "Error: tak
> take :: Int -> [a] -> [a]
>If you want to define your own take
> mytake :: Show a => Int -> [a] -> [a]
>that's fine, but it's a different function.
>
>And for (head []) there's really no useful info to hand. So I'm stumped.
Although you can't show the value (because there isn't one)
Sergey, I could not agree more. I sent the following message to the
Hugs implementors a few months ago.
I have taught Hugs for a couple of years and enjoy using it. Students
like to have a system they can take home and install for free, and the
system seems pretty robust. One problem s
| 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
As a relative novice who's been bitten by these things, I'd like to
second the request for more detailed "program error" messages.
When the question was last raised on comp.lang.functional, I think it
sort of concluded with a suggestion to add an 'error' case to some
Prelude functions, e.g inst
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
17 matches
Mail list logo