logo       

RE: Re[2]: the impossible happened: msg#00109

lang.haskell.glasgow.bugs

Subject: RE: Re[2]: the impossible happened

| also it will be cool to have ability to add such annotations to my own
| functions, smthg like:
|
| head (x:xs) = x
| head [] = superError "head []"
|
| which will print: "Error: head [] in Module.hs:155"

A difficulty is that the caller of 'head' might itself be called from
somewhere else:

foo (xs, ys) = head xs

It's not much help to know that head failed when called from foo; you
want to know where foo is called from. In short, you really want the
whole call stack. But trimmed in the recursive case...

It's all very like cost-centre stacks, which is why GHC provides the -xc
option when you are profiling. I think that give you what you want ---
but you have to compile your program profiled.

Another take on this is that you want an implicit parameter

head :: (%loc :: Location) => [a] -> a

so that 'head' can report %loc when it fails. Now you'd need to give
rules to say where %loc is bound. It'd be a pretty magic kind of
implicit parameter. Or should it be a stack of locations?


I'm not belittling the underlying problem, which is real. But there do
seem to be many possible design choices without an obvious optimium. If
someone can boil out a principled and simple solution, it'd be a good
contribution.

Simon


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise