How to debug Haskell code?

后端 未结 4 510
渐次进展
渐次进展 2020-12-04 11:06

I have a problem. I wrote a big Haskell program, and it always works with small input. Now, when I want to test it and generate a bigger input, I always get the message:

4条回答
  •  被撕碎了的回忆
    2020-12-04 11:37

    You may want to take a look at Haskell Wiki - Debugging, which contains many useful approaches to your problem.

    One promising tool is LocH, which would would help you locate the head invocation in your code which triggered the empty list error.

    Personally, I recommend the safe package, which allows to annotate most partial functions from the Prelude (and thus leads to a more conscious use of those partial functions) or better yet, use the total variants of functions such as head which always return a result (if the input value was defined at least).

提交回复
热议问题