[Haskell-beginners] can I use "pure" all the time instead of "return" now?

David Thomas davidleothomas at gmail.com
Sat May 14 21:54:22 UTC 2016


As I understand it, that's correct - you can use pure anywhere you'd
have used return.

On Sat, May 14, 2016 at 2:39 PM, Silent Leaf <silent.leaf0 at gmail.com> wrote:
> All in the title; Since the change in GHC, 7.10 i think, where all Monad
> instances had to have Applicative instances too, in theory all monads must
> have a pure method that should be identical to return, right?
>
> My subjectively superficial reason for preferring pure (and caring about the
> issue in the first place) is twofold: shorter (i know, i know, still the
> shorter, the quicker to read and then understand in the code) and, mostly,
> less semantically-awkward --honestly the name "stains" the functional
> semantics in Monadic code, in my opinion, but that's just personal. (For
> those who know, it feels like the "new" operator in JS (OO
> class-instanciation semantical imitation))
>
> Of course now I'm perfectly used to, have no trouble seeing it for what it
> is all the time, not mixing it up with some imperative-like "return"
> concept.
> Yet i don't really like it much at all, so I wanted to know to which extent
> it is safe to always use pure even in explicitly Monadic contexts.
>
> Thankx in advance!
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>


More information about the Beginners mailing list