Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a Haskell n00b, I'd like to mention something I can do in about 20 other languages but not in Haskell:

( UPDATE: I stand corrected, in a reply by tome. )

I'm writing and debugging some functional code - in Clojure. There's a function I've smoke-tested on its own but that's failing me with "real" data. Lacking a decent debugger for Clojure and being too lazy to isolate my problem into a test setup, my tool of choice is the lowly "debug print."

In Clojure, the body of a function is essentially imperative, and I can insert a `(println "label:" value)`. To do the same thing in Haskell, I'd have to restructure my whole damn program.

I understand the rationale for purity in Haskell, but sometimes I see it as badly standing in my way of accomplishing what I want to do.



Have you heard of Debug.Trace? It gives you exactly what you are looking for.

https://hackage.haskell.org/package/base-4.12.0.0/docs/Debug...


Wow, cool! Thanks. I hope to do more with Haskell once I retire, and this may stand me in good stead.

I think my point is still supported to some extent by the fact that this is knowledge from outside of the language that I'd need to know to accomplish. It's something I need someone helpful like yourself to tell me about. Also something that only works because this library deliberately breaks Haskell's rules.


> Wow, cool! Thanks. I hope to do more with Haskell once I retire, and this may stand me in good stead.

I'm glad it was helpful.

> It's something I need someone helpful like yourself to tell me about.

In general we're happy to help but it does annoy us when people make assumptions about what it's like to program in Haskell without actually trying it. If you'd like help I can suggest Haskell Reddit https://www.reddit.com/r/haskell/ or emailing me personally http://web.jaguarpaw.co.uk/~tom/contact

> something that only works because this library deliberately breaks Haskell's rules.

Only if you have very punitive assumptions about what Haskell's rules are, like those who have never used the language often do. People who actually write Haskell programs have other ideas.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: