How to display a backtrace for an Error thrown in Haskell

Viewed 3529

I'm currently debugging an algorithm I implemented in Haskell for my Diploma thesis. It seems to work correctly for most inputs, yet I found one input which makes GHC throw the error

*** Exception: Map.find: element not in the map

Since I have many Map lookups in my code, I need to find the line throwing this error to make any sense of it. I read through this guide, but although I set the flag fbreak-on-exception (and -error), all GHCi gives me after tracing the function I'm testing is:

[...]> :trace test
[...]
Stopped at <exception thrown>
_exception ::
  e = GHC.Exception.SomeException (GHC.Exception.D:Exception _
                                                         (GHC.Show.D:Show ...) ....)
                              (GHC.Exception.ErrorCall ['M',....])
Unable to list source for <exception thrown>
Try rerunning with :trace, :back then :list
[<exception thrown>] [...]> :history
Empty history. Perhaps you forgot to use :trace?

Trying :trace again doesn't seem to help either.

So, can someone tell me what is going wrong or offer another way of finding the offending line? Thanks in advance!

PS: I'm using GHC version 7.0.3, so the linked guide should apply.

1 Answers
Related