Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the return function called return?

Why is the return function called return?

The description is:

Inject a value into the monadic type.

The name not only doesn't make sense (to me), it is confusing for people coming from an imperative language where return is a language keyword that returns from the function.

like image 709
Sam Leach Avatar asked Mar 18 '14 21:03

Sam Leach


2 Answers

Why is it called that? Because it's usually the very last function in a monadic block of code. Usually the only good reason to use return is to set the final return value from your monadic action.

I too think that this is a very, very poor name choice. But it's not like we can fix it now...

like image 154
MathematicalOrchid Avatar answered Sep 19 '22 21:09

MathematicalOrchid


It's purely historical. Most Haskell developers agree it's a bad name. It breaks the principle of least surprise. Quite a few of the older library functions are a bit wonky (the plethora of error handling schemes and a few other typeclass element names come to mind).

As @bheklilr says, there is a restructuring underway which should help:

  • http://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal

These are good places to start if you are interested in the meta of Haskell:

  • http://www.haskell.org/haskellwiki/Future_of_Haskell
  • http://www.haskell.org/haskellwiki/Category:History
like image 41
Iain Ballard Avatar answered Sep 18 '22 21:09

Iain Ballard