3 ms·
Yes, 'return' is egregious. I believe it was co-designed with haskell's do-notation. So that you could write purely declarative code that was a spitting image o
by ky3 12y ago
Yes, 'return' is egregious. I believe it was co-designed with haskell's do-notation. So that you could write purely declarative code that was a spitting image of the imperative equivalent.
E.g.
x <- foo 2 -- x = foo(2)
y <- bar 4 -- y = bar(4)
return (x+y) -- return (x+y)
But something that's always missing in such discussions is that haskell allows you to define
a_better_word = return
and then you can freely forget about 'return' in your own code, except when you roll your own monad instances, which is rarer than a blue moon.
- dllthomas 12y agoWith AMP, it should always be possible to use pure in place of return. https://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal https://www.haskell.org/haskellwiki/Functor-Applicative-Mona...