What is a good way to debug haskell code?

前端 未结 4 889
野性不改
野性不改 2021-02-01 03:02

I have used the ghci debugger but would really prefer if it was somewhat integrated with a text editor to simplify the process of setting breakpoints. It should probably not str

4条回答
  •  长情又很酷
    2021-02-01 03:31

    For my own purposes I find that it's a combination of factors.

    1. Write easy to debug functional code, this means to make sure your functions are relatively small (5-20 lines) and that they only do one clearly defined thing each.
    2. Use HUnit to define test cases that will bring out your problems.

    As seen in other answers, a lot of people love QuickCheck. I've found it difficult to define meaningful QuickCheck test cases for at least some of my code so generally make more use of standard unit tests. That being said, there's an excellent introduction to using QuickCheck in Chapter 11 of Real World Haskell.

    Should you find yourself using both QuickCheck and HUnit, you may want to look into test-framework.

提交回复
热议问题