← Back to context

Comment by ericssmith

14 years ago

" was trying to express my frustration at not being able to insert a little impure code temporarily to tweak behaviour and help with debugging."

Why would you want to do that? Haskell is a functional language. You evaluate expressions, which can be done nicely in GHCI.

When I first learned Haskell, I was also trying to apply my procedural programming habits. Looking back, the pain was a sign of doing it wrong. Once I learned to look at solutions 'functionally', it turned out not to be a big deal, and the resulting code is arguably better. However, it does sometimes become painful going back to procedural languages.

One obvious reason would be if the input to your expression is relatively large or complex (e.g. a file).

  • That would not be obvious to me. I often have to process quite large and messy XML files and a functional approach works well. I'm not even sure how inserting print statements would be helpful.

    • There may be far better ways of doing it, but for a Haskell beginner (and I'm certainly one of those), being able to quickly display what each function was seeing as its input/returning as its result as it chugged through a complex file would have made life a lot easier for me when I first tried this kind of parsing in Haskell.