News for hackers. Stuff that matters.
Re:Learn Physics with Functional Programming by lmm on Wednesday September 06, 2023 @03:42AM (#37402343)
> Where do I have to 'understand "Monad"' to write this?

The recommended explanation of what <- is/does will be about "Monad".

Re:Learn Physics with Functional Programming by tome on Wednesday September 06, 2023 @04:33AM (#37402651)
You're moving the goalposts! You said 'the recommended way of writing a program to e.g. read two numbers from the user, add them, and print the result, demands understanding "Monad".'
Re:Learn Physics with Functional Programming by Tainnor on Wednesday September 06, 2023 @06:22PM (#37412209)
I don't think it's "moving the goalposts" when you demand that you can understand, at least to a first-order approximation, what the code that you write is doing.

Yes, you could just treat IO as a black box and memorize a bunch of weird syntax rules, but you're going to have a hard time very quickly, especially when you change something and the compiler throws errors at you.

FWIW, I think that monads are a powerful abstraction, but they're certainly not incredibly natural and Haskell basically just throws them at you from day 1.

Re:Learn Physics with Functional Programming by lmm on Wednesday September 06, 2023 @06:39PM (#37412412)
The recommended way of writing a program in most languages demands some level of understanding what you're writing. You would have to somehow come up with the "<-" parts of that program, and the recommended way of doing that is to understand Monad.
Re:Learn Physics with Functional Programming by tome on Thursday September 07, 2023 @03:00AM (#37415615)
> The recommended way of writing a program in most languages demands some level of understanding what you're writing

Sure, some. I think this discussion is about exactly what and how much, when it comes to Haskell.

> the recommended way of doing that is to understand Monad.

That doesn't ring true to me, not from how I learned Haskell and not by analogy with how I learned other languages. I don't remember having to "understand Monad" to write in "do" notation. Quite the opposite in fact. I vividly remember trying to "understand Monad" and being unable to, and then just giving up and trying to use do notation, finding it easy, completely unhelped by what I was trying to "understand", and regretting having spent all the time "understanding". But it's been a long time since I learned a language so maybe I'm mistaken. I would appreciate the point of view of others who have fresher eyes.

I will concede that people have a harder time learning Haskell than Python (although I don't think anyone understands the exact reasons) but you gave a very specific example of a program that is supposedly requires some deep understanding to write in Haskell. I wanted to give a counterpoint so people can decide for themselves. That's as far as my claim goes.