Call me old school but debugging in a console program is all about writing to
stderr. In my day-to-day programming (when I get the opportunity) that’s easily done: sprinkle the right
printlncall throughout the code. But in a strongly typed language like Purescript?
How can we see what our
makeMeAString function is actually doing? We could sprinkle it with
logShow from the
Contol.Monad.Aff module but that then adds a
CONSOLE effect to the function; if
makeMeAString was buried several level deep in a callstack then that would mean adding
CONSOLE to every single function. That’s just not going to cut it, especially as after finding the problem we’d then have to remove all of that.
@paf31 came through on Twitter with a much better suggestion:
With purescript-debug we can see the values as they pass through
makeMeAString by using the
spy :: a -> a function:
No effects needed.
There are other functions in purescript-debug that help old timers like myself. I was lucky to find the problem using just