Re:What I Wish I Knew When Learning Haskell
by amelius on Saturday April 11, 2020 @09:09AM
(#22841484)
But let's say I want to print something in a deeply nested function which isn't of the return-IO-Monad-type. Now I have to convert the entire call-chain of functions into Monad style. Is there some tool to do this automatically?
[ Parent
| on HN ]
Re:What I Wish I Knew When Learning Haskell
by kadoban on Saturday April 11, 2020 @10:06AM
(#22841735)
For debug there is Debug.Trace which is about perfect.
For non-debug, you may be overestimating how useful it is to output from pure functions in production.
In general when you are in a situation where you need to change the Monad you're under, there's techniques and libraries for that (one way you define it once, give it a name, etc.).
The biggest pain tends to be going from pure to monadic in the first place, which last I used Haskell there wasn't much for but to just do it. There may be more tooling now, haven't seen.
Re:What I Wish I Knew When Learning Haskell
by hopia on Saturday April 11, 2020 @10:13AM
(#22841765)
Why would you want to print inside a pure function though?
Re:What I Wish I Knew When Learning Haskell
by AnimalMuppet on Saturday April 11, 2020 @04:14PM
(#22843894)
Because some non-technical manager came to you and said, "Can't you just print out the value here? And can I get it in the next 15 minutes?" and it was pretty clear that "No" was not an acceptable answer.