How do I debug, since print statements change the type?

Because Haskell is pure and functional, the approach of debugging by adding print statements is not needed as often. Instead, you can inspect the subcomponents of your program and their types in isolation, and check their behavior in the repl.

However, when you do need print statements, you can use trace from Debug.Trace, like so:

repl example
> import Debug.Trace (trace)
> let output = take 10 [1..] in trace (("Length: " <> show (length output))) output
Length: 10

Last update: January 15, 2023
Created: January 7, 2023