can I use "pure" all the time instead of "return" now?

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!

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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

If/when Applicative Do drops, would using 'return' force monad semantics on
a do-block that could otherwise be applicative? That's the only thing that
comes to mind. Otherwise yeah, I've been using 'pure' exclusively for a
while.
On May 14, 2016 2:54 PM, "David Thomas"
As I understand it, that's correct - you can use pure anywhere you'd have used return.
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
On Sat, May 14, 2016 at 2:39 PM, Silent Leaf
wrote: 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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Hello,
If/when Applicative Do drops, would using 'return' force monad semantics on a do-block that could otherwise be applicative? That's the only thing that comes to mind. Otherwise yeah, I've been using 'pure' exclusively for a while.
I think so, at least until the "Monad of no return" proposal (https://ghc.haskell.org/trac/ghc/wiki/Proposal/MonadOfNoReturn) lands. Best regards, Marcin Mrotek

that's great news! Thanks to all your answers :)
Hope the "no return" proposal gets accepted and incorporated!
Le dimanche 15 mai 2016, Marcin Mrotek
Hello,
If/when Applicative Do drops, would using 'return' force monad semantics on a do-block that could otherwise be applicative? That's the only thing that comes to mind. Otherwise yeah, I've been using 'pure' exclusively for a while.
I think so, at least until the "Monad of no return" proposal (https://ghc.haskell.org/trac/ghc/wiki/Proposal/MonadOfNoReturn) lands.
Best regards, Marcin Mrotek _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (4)
-
David Thomas
-
Marcin Mrotek
-
Silent Leaf
-
Theodore Lief Gannon