|
|
|
|
|
by fortknots
4277 days ago
|
|
Actually, Haskell does let you write print statements for debugging. If we have the following function: foo :: Int -> Int
foo x = x `div` 0
and we want to add debugging, we can do: import Debug.Trace
foo :: Int -> Int
foo x
| trace (show x) False = undefined
| otherwise = x `div` 0
The above will print the value of x before throwing an error due to division by zero. You don't have to make foo return an IO Int or change any other aspect of your program. |
|