My experience with learning Haskell was: When it works, it's magical. Finally realising that monads allow little bubbles of cause-and-effect. STM, which is utterly magical. Realising that not having side effects is freeing, not restricting. Collapsing huge chunks of code into little bits of pattern matching. Finding myself casually using a higher-order type because it was the easiest way to solve a problem. When it's…
Personally, I've been spending a lot of my recent time trying to debug a Parsec parser (it seems to be going into loops of backtracking, but I can't figure out where and why ), and it's been a clusterfuck. * `trace` and `traceM` don't actually get evaluated, so I can't use printing to find my bugs. * Even putting `trace "..." True` as a guard to my parser combinators doesn't seem to actually print anything. * `seq` a…
To get a trace message, you need to attach the trace to something that does get evaluated. I mostly define a somewhat simpler helper like this:
tt :: Show a => a -> a
tt x = trace (show x) x
So you surround your expressions with it and see there values, when those values get evaluated of course. Eg: myParser = (\_ code -> tt code) parseComment parseCode