Re:Functional programming jargon in plain English
by garethrowlands on Monday July 04, 2022 @11:29AM
(#31978107)
While I broadly agree with you, I think the post you're responding to has a point. You can't, in general, get a value back out of a monad, so if you call a monadic function, you may well have to return a monad. The obvious example is IO: there's no (safe) way get the `a` from `IO a`, so IO is kinda contagious.
Then again, there are lots of monads, such as `Maybe` and `List`, where you can get values out. These aren't contagious at all.
I agree with you that this is a good thing. Effects show up in the type signature - and it's all about those effects and managing them.
Re:Functional programming jargon in plain English
by ratww on Monday July 04, 2022 @12:47PM
(#31979084)
Yes, this is what I mean. IO is contagious for reasons unrelated to it being a Monad.
Re:Functional programming jargon in plain English
by endgame on Monday July 04, 2022 @05:46PM
(#31982074)
I think that applicatives and monads feel more contagious than they really are, because at first people tend to write functions that consume values of type `f a` too readily. This is because it takes some time to become comfortable with `fmap` and friends, so the new Haskell programmer often doesn't write as many pure functions.
This is also true for other things in other paradigms, such as async functions in javascript.
This is a good thing, however. In imperative programming, you have invisible temporal coupling. In pure-FP you have the same coupling, but it's exposed.