views:

165

answers:

2

I am trying to track down a non-exhaustive pattern in a libraries code. Specifically HDBC's mysql implementation. It is trying to match over types in my program and map them to mysql's types I believe. I can't seem to get a callstack for this error which means that since there are a number of parameters to the SQL query it is difficult to track down exactly what is causing it.

Is it possible to get a callstack in haskell so I would know which parameter was causing the error? Also I would think that this should be caught by the compiler since it should be able to look at my types and the patterns and make sure that there was a corresponding match.

+8  A: 

You can use the GHCi debugger to identify where the exception is coming from.

I walk through a full example here.

Don Stewart
Thanks Don. I have not been able to get that to work due to an issue with ghci not being able to find the dynamic mysql libs. Loading package HDBC-mysql-0.6.2 ... can't load .so/.DLL for: mygcc (dlopen(libmygcc.dylib, 9): image not found)
Steve
You'll probably need to pass the path to the .so file on the command line.
Don Stewart
that is awesome! thanks Don, I'll have to remember that.
rampion
@Don Stewart: Sadly there's a problem with mysql on OS X, that lib links only statically..
yairchu
Got it all fixed up. If you comment out that entry in the cabal file that links in the static lib and then add the dynamic lib path in .bashrc it works. Never got a call stack but once I got the -prof libs for all my dependencies I actually got an informative error.
Steve
A: 

You might also take a look at the Debug.Trace library.

Axle
Although it has nothing to do with a stack trace -- it's a way to print outside of IO.
jrockway