
Hello *, frequently we are seeing messages like "List.head: empty list" or "Maybe.fromJust: Nothing". It is clear what happened and where the messages were triggered yet the real cause is usually VERY hard to find unless the program is small and simple. I came to the conclusion that functions like head and fromJust are best to be avoided because their use may render large programs unmaintainable. Instead I use irrefutable pattern matching like (x : _) = l and Just bla = maybeBla whenever possible because when a pattern match fails the ghc runtime system gives me a nice error message naming the module, line and column. However, this procedure may become tedious when the error occurs in a call to a third-party library function. I wonder whether it is possible to print a "closure trace" similar to a stack trace in procedural programming. Say we have two modules A and B: module A where import B a = b module B b = c where c = error "go to hell" I would like to see something like this: sh$ ghci A <ghci startup messages> > a Runtime error "go to hell" in module B at line 2 Trace: B.b.c B.b A.a This way it would be easy to find the reason that actually caused, say, head to fail. I guess it would be sufficient to complement closures with information on the precise place of their definition. Michael