pure instead of return?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

pure instead of return?

Silent Leaf
hi,

i just wanted to know, if i use pure instead of return, if there's any single risk of getting a different implementation of the function, or anything of that kind. also, am i right to assume that GHC will do what is needed so there's no actual redirection in the compiled code, in the case pure is defined in terms of return?

thanks

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Silent Leaf
btw: does the name of "pure" come from the idea that the monad IO is "impure" (which does not seem to be the case, does it?) or is it more of a mathematical concept of pure values vs values whose types are functors/applicatives/monads? or is it a way to say "simplest way to wrap the value, purest (least "modified") equivalent of the value as wrapped value"?

2017-07-01 15:09 GMT+02:00 Silent Leaf <[hidden email]>:
hi,

i just wanted to know, if i use pure instead of return, if there's any single risk of getting a different implementation of the function, or anything of that kind. also, am i right to assume that GHC will do what is needed so there's no actual redirection in the compiled code, in the case pure is defined in terms of return?

thanks


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Francesco Ariis
On Sat, Jul 01, 2017 at 07:47:57PM +0200, Silent Leaf wrote:
> [..] or is it a way to say "simplest way to wrap
> the value, purest (least "modified") equivalent of the value as wrapped
> value"?

^-- this one.

`pure` and `return` are synonyms. There are two words for the same concept
for historical reasons. Using pure does not incurs in monad constraints,
so if you can you might want to use that.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Silent Leaf
but i can use pure every time return is usable, can i not? every applicatives are monads right? i don't get the "if you can" part. why could i not?

2017-07-01 20:03 GMT+02:00 Francesco Ariis <[hidden email]>:
On Sat, Jul 01, 2017 at 07:47:57PM +0200, Silent Leaf wrote:
> [..] or is it a way to say "simplest way to wrap
> the value, purest (least "modified") equivalent of the value as wrapped
> value"?

^-- this one.

`pure` and `return` are synonyms. There are two words for the same concept
for historical reasons. Using pure does not incurs in monad constraints,
so if you can you might want to use that.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Stefan Risberg
Every monad is applicative, but every instance of applicative does not have a monad one

On 1 Jul. 2017 20:19, "Silent Leaf" <[hidden email]> wrote:
but i can use pure every time return is usable, can i not? every applicatives are monads right? i don't get the "if you can" part. why could i not?

2017-07-01 20:03 GMT+02:00 Francesco Ariis <[hidden email]>:
On Sat, Jul 01, 2017 at 07:47:57PM +0200, Silent Leaf wrote:
> [..] or is it a way to say "simplest way to wrap
> the value, purest (least "modified") equivalent of the value as wrapped
> value"?

^-- this one.

`pure` and `return` are synonyms. There are two words for the same concept
for historical reasons. Using pure does not incurs in monad constraints,
so if you can you might want to use that.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Silent Leaf
yeah i know, so why did you say "so if you can you might want to use that"?

2017-07-01 21:46 GMT+02:00 Stefan Risberg <[hidden email]>:
Every monad is applicative, but every instance of applicative does not have a monad one

On 1 Jul. 2017 20:19, "Silent Leaf" <[hidden email]> wrote:
but i can use pure every time return is usable, can i not? every applicatives are monads right? i don't get the "if you can" part. why could i not?

2017-07-01 20:03 GMT+02:00 Francesco Ariis <[hidden email]>:
On Sat, Jul 01, 2017 at 07:47:57PM +0200, Silent Leaf wrote:
> [..] or is it a way to say "simplest way to wrap
> the value, purest (least "modified") equivalent of the value as wrapped
> value"?

^-- this one.

`pure` and `return` are synonyms. There are two words for the same concept
for historical reasons. Using pure does not incurs in monad constraints,
so if you can you might want to use that.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Francesco Ariis
In reply to this post by Silent Leaf
On Sat, Jul 01, 2017 at 08:18:57PM +0200, Silent Leaf wrote:
> but i can use pure every time return is usable, can i not? every
> applicatives are monads right? i don't get the "if you can" part. why could
> i not?

Say I am contributing to a project, and they use `return`, I am not going
die on the `pure` hill, you just go with what the style is.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pure instead of return?

Silent Leaf
ok, got it; yes you're right. though mind you it's so barely used i'm not sure it'd really break the style that much. but depends on whoever else is in the boat.

2017-07-01 22:03 GMT+02:00 Francesco Ariis <[hidden email]>:
On Sat, Jul 01, 2017 at 08:18:57PM +0200, Silent Leaf wrote:
> but i can use pure every time return is usable, can i not? every
> applicatives are monads right? i don't get the "if you can" part. why could
> i not?

Say I am contributing to a project, and they use `return`, I am not going
die on the `pure` hill, you just go with what the style is.
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Loading...