I need to debug some haskell code and figure out where an issue is occuring at runtime. When I run my program is says this
main: Prelude.(!!): index too large
which leads me to believe that there is a place I'm sending a list to a function that I really shouldn't be, and I don't know where. This is a 600+ line semantic analysis program. Trouble is, I can't for the life of me figure out where this !! error is. The debugging documentation is really confusing, and I can't get GHCI to cooperate so I can maybe figure this out. Whenever I run ghci main.hs, this happens:
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main>
I cannot seem to get it to turn to
*Main>
so that I can actually set breakpoints and all that fun stuff. How do I get this to work?
The former line means you are loading the file in compiled mode. You can fix this by making sure that there is no compiled version of the file around; or you can tell ghci to use interpreted mode by prepending a * when loading the file:
Prelude Main> :l *Main
*Main>
(Or run ghci '*Main.hs' -- adapted to your shell's escaping needs as appropriate.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With