6 ms·
If someone would make a tutorial that replicates the process you just described, that might be a good way to teach monads.
by javert 5y ago
If someone would make a tutorial that replicates the process you just described, that might be a good way to teach monads.
- ghayes 5y agoI strongly suggest starting with a language like Elm to get into FP, since you start to use `map` and `andThen` quite often, but you also get sick of writing `a |> Result.andThen fn1 |> Result.andThen fn2`. This can help a programmer realize why it might be better to have a concise syntax for this, like: myFun : String -> Result String Int myFun a = do b <- fn1 a c <- fn2 b return c That said, I think the other problem with Haskell is the definition of the bind operator: it is not obvious to a beginner which concrete function is actually being called for each monadic operation. Idris2, for instance, lets you specify the bind operator in its do notation[0]. [0] https://idris2.readthedocs.io/en/latest/tutorial/interfaces.html https://idris2.readthedocs.io/en/latest/tutorial/interfaces....
- exdsq 5y agoI think it'd become Just Another Monad Tutorial. Its something that clicks after a bit of FP programming without monads. Simon Peyton-Jones wrote a good paper about how IO worked prior to Monads which is nice - context helps with these things. I remember struggling to understand OO until I got my first junior dev role so I do think it's just practice practice practice to get through these things.
- hwayne 5y agoIMO it's probably better to teach the use of applicatives first and then monads.
- akdor1154 5y agoThe Railway Oriented Programming section in F# For Fun And Profit is basically this.