bind :: Monad m => (a -> m b) -> m a -> m b

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
36 messages Options
12
Reply | Threaded
Open this post in threaded view
|

bind :: Monad m => (a -> m b) -> m a -> m b

Christopher Done-2

Is this defined anywhere in base, and if not could it be placed in
Control.Monad? I often find myself writing:

fmap (mu bar)
     (foo zot)

Then I decide to change the type of x, so instead I want to just
write:

bind (mu bar)
     (foo zot)

Which is just like fmap but the function can run in the
monad. Similar to traverse:

(Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

As someone who isn’t a fan of operators, I generally am appreciative
of alternative regular plain English word versions of functions, which
I find easier to type, read and edit. Currently without defining such
a handy name, I have to transform the code to this:

mu bar =<<
foo zot

The name for this function is a no-brainer:

bind :: Monad m => (a -> m b) -> m a -> m b
bind = (=<<)

For comparison, the not-very-pleasant <$> and <*> each have word
alternatives, fmap and ap. Even <> has mappend.

I don’t hold much hope for this, Haskellers love operators as much as
Perl programmers so few on this list will see the value in plain old
words, but at least I can link to this email in the archives for
future reference.

Ciao


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

David Feuer

On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]> wrote:
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m b
> bind = (=<<)

Since most people use the term "bind" to refer to the >>= operator, this would be very confusing.

> For comparison, the not-very-pleasant <$> and <*> each have word
> alternatives, fmap and ap. Even <> has mappend.

fmap predates <$>, and <$> tends to be used only in certain contexts. "ap" has a narrower type than <*>.

> I don’t hold much hope for this, Haskellers love operators as much as
> Perl programmers so few on this list will see the value in plain old
> words, but at least I can link to this email in the archives for
> future reference.

I have nothing against the idea in principle, but that name won't fly.


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Bob Ippolito
In reply to this post by Christopher Done-2
+1 from me, I would love to have named versions of these operators.

Does `ap` still have a Monad constraint or has it been changed to match the Applicative `<*>` after AMP?

On Tue, Dec 9, 2014 at 1:44 PM, Christopher Done <[hidden email]> wrote:

Is this defined anywhere in base, and if not could it be placed in
Control.Monad? I often find myself writing:

fmap (mu bar)
     (foo zot)

Then I decide to change the type of x, so instead I want to just
write:

bind (mu bar)
     (foo zot)

Which is just like fmap but the function can run in the
monad. Similar to traverse:

(Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

As someone who isn’t a fan of operators, I generally am appreciative
of alternative regular plain English word versions of functions, which
I find easier to type, read and edit. Currently without defining such
a handy name, I have to transform the code to this:

mu bar =<<
foo zot

The name for this function is a no-brainer:

bind :: Monad m => (a -> m b) -> m a -> m b
bind = (=<<)

For comparison, the not-very-pleasant <$> and <*> each have word
alternatives, fmap and ap. Even <> has mappend.

I don’t hold much hope for this, Haskellers love operators as much as
Perl programmers so few on this list will see the value in plain old
words, but at least I can link to this email in the archives for
future reference.

Ciao


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Christopher Allen
I'd love to have a "bind" with that nice symmetry with fmap for both personal use and for pedagogical purposes. I use precisely that function by that name to help teach monads already.

On Tue, Dec 9, 2014 at 3:55 PM, Bob Ippolito <[hidden email]> wrote:
+1 from me, I would love to have named versions of these operators.

Does `ap` still have a Monad constraint or has it been changed to match the Applicative `<*>` after AMP?

On Tue, Dec 9, 2014 at 1:44 PM, Christopher Done <[hidden email]> wrote:

Is this defined anywhere in base, and if not could it be placed in
Control.Monad? I often find myself writing:

fmap (mu bar)
     (foo zot)

Then I decide to change the type of x, so instead I want to just
write:

bind (mu bar)
     (foo zot)

Which is just like fmap but the function can run in the
monad. Similar to traverse:

(Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

As someone who isn’t a fan of operators, I generally am appreciative
of alternative regular plain English word versions of functions, which
I find easier to type, read and edit. Currently without defining such
a handy name, I have to transform the code to this:

mu bar =<<
foo zot

The name for this function is a no-brainer:

bind :: Monad m => (a -> m b) -> m a -> m b
bind = (=<<)

For comparison, the not-very-pleasant <$> and <*> each have word
alternatives, fmap and ap. Even <> has mappend.

I don’t hold much hope for this, Haskellers love operators as much as
Perl programmers so few on this list will see the value in plain old
words, but at least I can link to this email in the archives for
future reference.

Ciao


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Christopher Allen
Sorry, if that wasn't obvious, that was a +1.

On Tue, Dec 9, 2014 at 3:59 PM, Christopher Allen <[hidden email]> wrote:
I'd love to have a "bind" with that nice symmetry with fmap for both personal use and for pedagogical purposes. I use precisely that function by that name to help teach monads already.

On Tue, Dec 9, 2014 at 3:55 PM, Bob Ippolito <[hidden email]> wrote:
+1 from me, I would love to have named versions of these operators.

Does `ap` still have a Monad constraint or has it been changed to match the Applicative `<*>` after AMP?

On Tue, Dec 9, 2014 at 1:44 PM, Christopher Done <[hidden email]> wrote:

Is this defined anywhere in base, and if not could it be placed in
Control.Monad? I often find myself writing:

fmap (mu bar)
     (foo zot)

Then I decide to change the type of x, so instead I want to just
write:

bind (mu bar)
     (foo zot)

Which is just like fmap but the function can run in the
monad. Similar to traverse:

(Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

As someone who isn’t a fan of operators, I generally am appreciative
of alternative regular plain English word versions of functions, which
I find easier to type, read and edit. Currently without defining such
a handy name, I have to transform the code to this:

mu bar =<<
foo zot

The name for this function is a no-brainer:

bind :: Monad m => (a -> m b) -> m a -> m b
bind = (=<<)

For comparison, the not-very-pleasant <$> and <*> each have word
alternatives, fmap and ap. Even <> has mappend.

I don’t hold much hope for this, Haskellers love operators as much as
Perl programmers so few on this list will see the value in plain old
words, but at least I can link to this email in the archives for
future reference.

Ciao


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries




_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Joseph Abrahamson
In reply to this post by Bob Ippolito
I’m +1 on this. Not only is it nice to sometimes have a non-operator (>>=) but it’s nice to have a function which more obviously lifts Kleisli arrows to monad arrows. Since it’s all aesthetics here, I think `bind f` is nice.

Bob, ap is useful with the Monad constraint because it lets you define (<*>) just using an already written Monad instance. It looks like it’s staying that way too

https://github.com/ghc/ghc/blob/master/libraries/base/GHC/Base.hs#L603



On Tue, Dec 9, 2014 at 4:55 PM, Bob Ippolito <[hidden email]> wrote:

+1 from me, I would love to have named versions of these operators.

Does `ap` still have a Monad constraint or has it been changed to match the Applicative `<*>` after AMP?

On Tue, Dec 9, 2014 at 1:44 PM, Christopher Done <[hidden email]> wrote:

Is this defined anywhere in base, and if not could it be placed in
Control.Monad? I often find myself writing:

fmap (mu bar)
     (foo zot)

Then I decide to change the type of x, so instead I want to just
write:

bind (mu bar)
     (foo zot)

Which is just like fmap but the function can run in the
monad. Similar to traverse:

(Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

As someone who isn’t a fan of operators, I generally am appreciative
of alternative regular plain English word versions of functions, which
I find easier to type, read and edit. Currently without defining such
a handy name, I have to transform the code to this:

mu bar =<<
foo zot

The name for this function is a no-brainer:

bind :: Monad m => (a -> m b) -> m a -> m b
bind = (=<<)

For comparison, the not-very-pleasant <$> and <*> each have word
alternatives, fmap and ap. Even <> has mappend.

I don’t hold much hope for this, Haskellers love operators as much as
Perl programmers so few on this list will see the value in plain old
words, but at least I can link to this email in the archives for
future reference.

Ciao


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries




_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Gabriel Gonzalez
In reply to this post by David Feuer
My understanding was that bind historically referred to `(=<<)`, not `(>>=)`

Either way I am (+1) on this, even if my previous sentence is false.

On 12/9/14, 1:55 PM, David Feuer wrote:

On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]> wrote:
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m b
> bind = (=<<)

Since most people use the term "bind" to refer to the >>= operator, this would be very confusing.

> For comparison, the not-very-pleasant <$> and <*> each have word
> alternatives, fmap and ap. Even <> has mappend.

fmap predates <$>, and <$> tends to be used only in certain contexts. "ap" has a narrower type than <*>.

> I don’t hold much hope for this, Haskellers love operators as much as
> Perl programmers so few on this list will see the value in plain old
> words, but at least I can link to this email in the archives for
> future reference.

I have nothing against the idea in principle, but that name won't fly.



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

David Feuer
It's possible I got confused by GHC.Base, which defines

bindIO :: IO a -> (a -> IO b) -> IO b

If that's backwards, then go right ahead and use bind to mean (=<<).

On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez <[hidden email]> wrote:
My understanding was that bind historically referred to `(=<<)`, not `(>>=)`

Either way I am (+1) on this, even if my previous sentence is false.


On 12/9/14, 1:55 PM, David Feuer wrote:

On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]> wrote:
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m b
> bind = (=<<)

Since most people use the term "bind" to refer to the >>= operator, this would be very confusing.

> For comparison, the not-very-pleasant <$> and <*> each have word
> alternatives, fmap and ap. Even <> has mappend.

fmap predates <$>, and <$> tends to be used only in certain contexts. "ap" has a narrower type than <*>.

> I don’t hold much hope for this, Haskellers love operators as much as
> Perl programmers so few on this list will see the value in plain old
> words, but at least I can link to this email in the archives for
> future reference.

I have nothing against the idea in principle, but that name won't fly.



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Andreas Abel-2
If there is a bindIO as specialization of (>>=), having a bind as alias
for (=<<) is a bad idea.

In category theory (Kleisli triple), (=<<) is called the extension operator.

Most of my uses of (=<<) are infix, as a monadic application operator,
so I never felt the need to have a non-operator version of it.

Haskell is all about saving parentheses and being not Scheme, so

   f a =<< g b

is definitely preferable over

   bind (f a) (g b)

;-)

Cheers,
Andreas

On 10.12.2014 00:35, David Feuer wrote:

> It's possible I got confused by GHC.Base, which defines
>
> bindIO :: IO a -> (a -> IO b) -> IO b
>
> If that's backwards, then go right ahead and use bind to mean (=<<).
>
> On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     My understanding was that bind historically referred to `(=<<)`, not
>     `(>>=)`
>
>     Either way I am (+1) on this, even if my previous sentence is false.
>
>
>     On 12/9/14, 1:55 PM, David Feuer wrote:
>>
>>     On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]
>>     <mailto:[hidden email]>> wrote:
>>     > The name for this function is a no-brainer:
>>     >
>>     > bind :: Monad m => (a -> m b) -> m a -> m b
>>     > bind = (=<<)
>>
>>     Since most people use the term "bind" to refer to the >>=
>>     operator, this would be very confusing.
>>
>>     > For comparison, the not-very-pleasant <$> and <*> each have word
>>     > alternatives, fmap and ap. Even <> has mappend.
>>
>>     fmap predates <$>, and <$> tends to be used only in certain
>>     contexts. "ap" has a narrower type than <*>.
>>
>>     > I don’t hold much hope for this, Haskellers love operators as
>>     much as
>>     > Perl programmers so few on this list will see the value in plain old
>>     > words, but at least I can link to this email in the archives for
>>     > future reference.
>>
>>     I have nothing against the idea in principle, but that name won't fly.
>>
>>
>>
>>     _______________________________________________
>>     Libraries mailing list
>>     [hidden email]  <mailto:[hidden email]>
>>     http://www.haskell.org/mailman/listinfo/libraries
>
>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
>


--
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

[hidden email]
http://www2.tcs.ifi.lmu.de/~abel/
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Felipe Lessa
I'm not sure what Abel's vote is, but I'm -1 on this proposal precisely
because of the issues he explained below.

Cheers,

On 09-12-2014 23:44, Andreas Abel wrote:

> If there is a bindIO as specialization of (>>=), having a bind as alias
> for (=<<) is a bad idea.
>
> In category theory (Kleisli triple), (=<<) is called the extension
> operator.
>
> Most of my uses of (=<<) are infix, as a monadic application operator,
> so I never felt the need to have a non-operator version of it.
>
> Haskell is all about saving parentheses and being not Scheme, so
>
>   f a =<< g b
>
> is definitely preferable over
>
>   bind (f a) (g b)
>
> ;-)
>
> Cheers,
> Andreas
>
> On 10.12.2014 00:35, David Feuer wrote:
>> It's possible I got confused by GHC.Base, which defines
>>
>> bindIO :: IO a -> (a -> IO b) -> IO b
>>
>> If that's backwards, then go right ahead and use bind to mean (=<<).
>>
>> On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     My understanding was that bind historically referred to `(=<<)`, not
>>     `(>>=)`
>>
>>     Either way I am (+1) on this, even if my previous sentence is false.
>>
>>
>>     On 12/9/14, 1:55 PM, David Feuer wrote:
>>>
>>>     On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]
>>>     <mailto:[hidden email]>> wrote:
>>>     > The name for this function is a no-brainer:
>>>     >
>>>     > bind :: Monad m => (a -> m b) -> m a -> m b
>>>     > bind = (=<<)
>>>
>>>     Since most people use the term "bind" to refer to the >>=
>>>     operator, this would be very confusing.
>>>
>>>     > For comparison, the not-very-pleasant <$> and <*> each have word
>>>     > alternatives, fmap and ap. Even <> has mappend.
>>>
>>>     fmap predates <$>, and <$> tends to be used only in certain
>>>     contexts. "ap" has a narrower type than <*>.
>>>
>>>     > I don’t hold much hope for this, Haskellers love operators as
>>>     much as
>>>     > Perl programmers so few on this list will see the value in
>>> plain old
>>>     > words, but at least I can link to this email in the archives for
>>>     > future reference.
>>>
>>>     I have nothing against the idea in principle, but that name won't
>>> fly.
>>>
>>>
>>>
>>>     _______________________________________________
>>>     Libraries mailing list
>>>     [hidden email]  <mailto:[hidden email]>
>>>     http://www.haskell.org/mailman/listinfo/libraries
>>
>>
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>
>
--
Felipe.


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

David Feuer
I should mention that LYAH, in
http://learnyouahaskell.com/a-fistful-of-monads , says

    The >>= function is pronounced as bind.

RWH, in, http://book.realworldhaskell.org/read/monads.html , indicates

    Here, (>>=) is our chaining function. [...] It's often referred to
as “bind”, as it binds the result of the computation on the left to
the parameter of the one on the right.

A Gentle Introduction to Haskell, at
https://www.haskell.org/tutorial/monads.html , says

    The Monad class defines two basic operators: >>= (bind) and return.

http://en.wikibooks.org/wiki/Haskell/Understanding_monads#Definition says

    an operator (>>=) which is pronounced "bind".

In case it's not clear yet, I am firmly against using the name "bind"
to mean (=<<).


On Tue, Dec 9, 2014 at 10:24 PM, Felipe Lessa <[hidden email]> wrote:

> I'm not sure what Abel's vote is, but I'm -1 on this proposal precisely
> because of the issues he explained below.
>
> Cheers,
>
> On 09-12-2014 23:44, Andreas Abel wrote:
>> If there is a bindIO as specialization of (>>=), having a bind as alias
>> for (=<<) is a bad idea.
>>
>> In category theory (Kleisli triple), (=<<) is called the extension
>> operator.
>>
>> Most of my uses of (=<<) are infix, as a monadic application operator,
>> so I never felt the need to have a non-operator version of it.
>>
>> Haskell is all about saving parentheses and being not Scheme, so
>>
>>   f a =<< g b
>>
>> is definitely preferable over
>>
>>   bind (f a) (g b)
>>
>> ;-)
>>
>> Cheers,
>> Andreas
>>
>> On 10.12.2014 00:35, David Feuer wrote:
>>> It's possible I got confused by GHC.Base, which defines
>>>
>>> bindIO :: IO a -> (a -> IO b) -> IO b
>>>
>>> If that's backwards, then go right ahead and use bind to mean (=<<).
>>>
>>> On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>>     My understanding was that bind historically referred to `(=<<)`, not
>>>     `(>>=)`
>>>
>>>     Either way I am (+1) on this, even if my previous sentence is false.
>>>
>>>
>>>     On 12/9/14, 1:55 PM, David Feuer wrote:
>>>>
>>>>     On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]
>>>>     <mailto:[hidden email]>> wrote:
>>>>     > The name for this function is a no-brainer:
>>>>     >
>>>>     > bind :: Monad m => (a -> m b) -> m a -> m b
>>>>     > bind = (=<<)
>>>>
>>>>     Since most people use the term "bind" to refer to the >>=
>>>>     operator, this would be very confusing.
>>>>
>>>>     > For comparison, the not-very-pleasant <$> and <*> each have word
>>>>     > alternatives, fmap and ap. Even <> has mappend.
>>>>
>>>>     fmap predates <$>, and <$> tends to be used only in certain
>>>>     contexts. "ap" has a narrower type than <*>.
>>>>
>>>>     > I don’t hold much hope for this, Haskellers love operators as
>>>>     much as
>>>>     > Perl programmers so few on this list will see the value in
>>>> plain old
>>>>     > words, but at least I can link to this email in the archives for
>>>>     > future reference.
>>>>
>>>>     I have nothing against the idea in principle, but that name won't
>>>> fly.
>>>>
>>>>
>>>>
>>>>     _______________________________________________
>>>>     Libraries mailing list
>>>>     [hidden email]  <mailto:[hidden email]>
>>>>     http://www.haskell.org/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> [hidden email]
>>> http://www.haskell.org/mailman/listinfo/libraries
>>>
>>
>>
>
> --
> Felipe.
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
>
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Gershom Bazerman
I humbly suggest, “dnib”.

What could be clearer?

-g


On December 9, 2014 at 10:44:59 PM, David Feuer ([hidden email]) wrote:

> I should mention that LYAH, in
> http://learnyouahaskell.com/a-fistful-of-monads , says
>  
> The >>= function is pronounced as bind.
>  
> RWH, in, http://book.realworldhaskell.org/read/monads.html , indicates
>  
> Here, (>>=) is our chaining function. [...] It's often referred to
> as “bind”, as it binds the result of the computation on the left to
> the parameter of the one on the right.
>  
> A Gentle Introduction to Haskell, at
> https://www.haskell.org/tutorial/monads.html , says
>  
> The Monad class defines two basic operators: >>= (bind) and return.
>  
> http://en.wikibooks.org/wiki/Haskell/Understanding_monads#Definition says  
>  
> an operator (>>=) which is pronounced "bind".
>  
> In case it's not clear yet, I am firmly against using the name "bind"
> to mean (=<<).
>  
>  
> On Tue, Dec 9, 2014 at 10:24 PM, Felipe Lessa wrote:
> > I'm not sure what Abel's vote is, but I'm -1 on this proposal precisely
> > because of the issues he explained below.
> >
> > Cheers,
> >
> > On 09-12-2014 23:44, Andreas Abel wrote:
> >> If there is a bindIO as specialization of (>>=), having a bind as alias
> >> for (=<<) is a bad idea.
> >>
> >> In category theory (Kleisli triple), (=<<) is called the extension
> >> operator.
> >>
> >> Most of my uses of (=<<) are infix, as a monadic application operator,
> >> so I never felt the need to have a non-operator version of it.
> >>
> >> Haskell is all about saving parentheses and being not Scheme, so
> >>
> >> f a =<< g b
> >>
> >> is definitely preferable over
> >>
> >> bind (f a) (g b)
> >>
> >> ;-)
> >>
> >> Cheers,
> >> Andreas
> >>
> >> On 10.12.2014 00:35, David Feuer wrote:
> >>> It's possible I got confused by GHC.Base, which defines
> >>>
> >>> bindIO :: IO a -> (a -> IO b) -> IO b
> >>>
> >>> If that's backwards, then go right ahead and use bind to mean (=<<).
> >>>
> >>> On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez > >>> > wrote:
> >>>
> >>> My understanding was that bind historically referred to `(=<<)`, not
> >>> `(>>=)`
> >>>
> >>> Either way I am (+1) on this, even if my previous sentence is false.
> >>>
> >>>
> >>> On 12/9/14, 1:55 PM, David Feuer wrote:
> >>>>
> >>>> On Dec 9, 2014 4:44 PM, "Christopher Done" > >>>> > wrote:
> >>>> > The name for this function is a no-brainer:
> >>>> >
> >>>> > bind :: Monad m => (a -> m b) -> m a -> m b
> >>>> > bind = (=<<)
> >>>>
> >>>> Since most people use the term "bind" to refer to the >>=
> >>>> operator, this would be very confusing.
> >>>>
> >>>> > For comparison, the not-very-pleasant <$> and <*> each have word
> >>>> > alternatives, fmap and ap. Even <> has mappend.
> >>>>
> >>>> fmap predates <$>, and <$> tends to be used only in certain
> >>>> contexts. "ap" has a narrower type than <*>.
> >>>>
> >>>> > I don’t hold much hope for this, Haskellers love operators as
> >>>> much as
> >>>> > Perl programmers so few on this list will see the value in
> >>>> plain old
> >>>> > words, but at least I can link to this email in the archives for
> >>>> > future reference.
> >>>>
> >>>> I have nothing against the idea in principle, but that name won't
> >>>> fly.
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> Libraries mailing list
> >>>> [hidden email]  
> >>>> http://www.haskell.org/mailman/listinfo/libraries
> >>>
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Libraries mailing list
> >>> [hidden email]
> >>> http://www.haskell.org/mailman/listinfo/libraries
> >>>
> >>
> >>
> >
> > --
> > Felipe.
> >
> >
> > _______________________________________________
> > Libraries mailing list
> > [hidden email]
> > http://www.haskell.org/mailman/listinfo/libraries
> >
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
>  

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Niklas Haas
In reply to this post by Christopher Done-2
Possible name:

joinMap :: Monad m => (a -> m b) -> m a -> m b
corresponds to
concatMap :: (a -> [b]) -> [a] -> [b]
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

David Feuer
I'm +1 on joinMap.

On Tue, Dec 9, 2014 at 10:57 PM, Niklas Haas <[hidden email]> wrote:
> Possible name:
>
> joinMap :: Monad m => (a -> m b) -> m a -> m b
> corresponds to
> concatMap :: (a -> [b]) -> [a] -> [b]
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Alexander Berntsen
In reply to this post by Christopher Done-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

- -1 for the name "bind". ±0 for everything else.
- --
Alexander
[hidden email]
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlSIAlYACgkQRtClrXBQc7UxygEAjL7k2UYggulrVIKbG1r5z528
kCgRZbx7rSgIm2lsATEA/1MSCFUUkgjZcRQYRaQ0Z6ZXCCM9Xay3DAigd4QVl4aD
=oq8v
-----END PGP SIGNATURE-----
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Andreas Abel-2
In reply to this post by David Feuer
Possible names would be

   applyM, appM :: Monad m => (a -> m b) -> m a -> m b

because this is an application function, albeit on a monadic value.

Cheers,
Andreas

On 10.12.2014 04:44, David Feuer wrote:

> I should mention that LYAH, in
> http://learnyouahaskell.com/a-fistful-of-monads , says
>
>      The >>= function is pronounced as bind.
>
> RWH, in, http://book.realworldhaskell.org/read/monads.html , indicates
>
>      Here, (>>=) is our chaining function. [...] It's often referred to
> as “bind”, as it binds the result of the computation on the left to
> the parameter of the one on the right.
>
> A Gentle Introduction to Haskell, at
> https://www.haskell.org/tutorial/monads.html , says
>
>      The Monad class defines two basic operators: >>= (bind) and return.
>
> http://en.wikibooks.org/wiki/Haskell/Understanding_monads#Definition says
>
>      an operator (>>=) which is pronounced "bind".
>
> In case it's not clear yet, I am firmly against using the name "bind"
> to mean (=<<).
>
>
> On Tue, Dec 9, 2014 at 10:24 PM, Felipe Lessa <[hidden email]> wrote:
>> I'm not sure what Abel's vote is, but I'm -1 on this proposal precisely
>> because of the issues he explained below.
>>
>> Cheers,
>>
>> On 09-12-2014 23:44, Andreas Abel wrote:
>>> If there is a bindIO as specialization of (>>=), having a bind as alias
>>> for (=<<) is a bad idea.
>>>
>>> In category theory (Kleisli triple), (=<<) is called the extension
>>> operator.
>>>
>>> Most of my uses of (=<<) are infix, as a monadic application operator,
>>> so I never felt the need to have a non-operator version of it.
>>>
>>> Haskell is all about saving parentheses and being not Scheme, so
>>>
>>>    f a =<< g b
>>>
>>> is definitely preferable over
>>>
>>>    bind (f a) (g b)
>>>
>>> ;-)
>>>
>>> Cheers,
>>> Andreas
>>>
>>> On 10.12.2014 00:35, David Feuer wrote:
>>>> It's possible I got confused by GHC.Base, which defines
>>>>
>>>> bindIO :: IO a -> (a -> IO b) -> IO b
>>>>
>>>> If that's backwards, then go right ahead and use bind to mean (=<<).
>>>>
>>>> On Tue, Dec 9, 2014 at 6:17 PM, Gabriel Gonzalez <[hidden email]
>>>> <mailto:[hidden email]>> wrote:
>>>>
>>>>      My understanding was that bind historically referred to `(=<<)`, not
>>>>      `(>>=)`
>>>>
>>>>      Either way I am (+1) on this, even if my previous sentence is false.
>>>>
>>>>
>>>>      On 12/9/14, 1:55 PM, David Feuer wrote:
>>>>>
>>>>>      On Dec 9, 2014 4:44 PM, "Christopher Done" <[hidden email]
>>>>>      <mailto:[hidden email]>> wrote:
>>>>>      > The name for this function is a no-brainer:
>>>>>      >
>>>>>      > bind :: Monad m => (a -> m b) -> m a -> m b
>>>>>      > bind = (=<<)
>>>>>
>>>>>      Since most people use the term "bind" to refer to the >>=
>>>>>      operator, this would be very confusing.
>>>>>
>>>>>      > For comparison, the not-very-pleasant <$> and <*> each have word
>>>>>      > alternatives, fmap and ap. Even <> has mappend.
>>>>>
>>>>>      fmap predates <$>, and <$> tends to be used only in certain
>>>>>      contexts. "ap" has a narrower type than <*>.
>>>>>
>>>>>      > I don’t hold much hope for this, Haskellers love operators as
>>>>>      much as
>>>>>      > Perl programmers so few on this list will see the value in
>>>>> plain old
>>>>>      > words, but at least I can link to this email in the archives for
>>>>>      > future reference.
>>>>>
>>>>>      I have nothing against the idea in principle, but that name won't
>>>>> fly.
>>>>>
>>>>>
>>>>>
>>>>>      _______________________________________________
>>>>>      Libraries mailing list
>>>>>      [hidden email]  <mailto:[hidden email]>
>>>>>      http://www.haskell.org/mailman/listinfo/libraries
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Libraries mailing list
>>>> [hidden email]
>>>> http://www.haskell.org/mailman/listinfo/libraries
>>>>
>>>
>>>
>>
>> --
>> Felipe.
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/libraries
>>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
>


--
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

[hidden email]
http://www2.tcs.ifi.lmu.de/~abel/
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Oliver Charles-3
In reply to this post by Christopher Done-2
Christopher Done <[hidden email]> writes:

> Is this defined anywhere in base, and if not could it be placed in
> Control.Monad? I often find myself writing:
>
> fmap (mu bar)
>      (foo zot)
>
> Then I decide to change the type of x, so instead I want to just
> write:
>
> bind (mu bar)
>      (foo zot)
>
> Which is just like fmap but the function can run in the
> monad. Similar to traverse:
>
> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
>
> As someone who isn’t a fan of operators, I generally am appreciative
> of alternative regular plain English word versions of functions, which
> I find easier to type, read and edit. Currently without defining such
> a handy name, I have to transform the code to this:
>
> mu bar =<<foo zot
>
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m bbind = (=<<)
I'm -1 on the *name* `bind`, because as others have mentioned, I feel bind
has the same type as (>>=).

That said, I'm +1 on the *idea* - if we can find a better name. `joinMap`
doesn't seem too bad, as was recently suggested, but I'll settle on
anything other than `bind`

-- ocharles

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries

signature.asc (482 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

David Feuer

joinMap looks to me like the best name, because it does just what it says on the box:

join . fmap f $ m
= (m >>= return . f) >>= id --Functor/Monad law
= m >>= (\x -> return (f x) >>= id) --associativity
= m >>= (\x -> f x) --left identity
= m >>= f --eta reduction
= f =<< m

Christopher Done <[hidden email]> writes:

> Is this defined anywhere in base, and if not could it be placed in
> Control.Monad? I often find myself writing:
>
> fmap (mu bar)
>      (foo zot)
>
> Then I decide to change the type of x, so instead I want to just
> write:
>
> bind (mu bar)
>      (foo zot)
>
> Which is just like fmap but the function can run in the
> monad. Similar to traverse:
>
> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
>
> As someone who isn’t a fan of operators, I generally am appreciative
> of alternative regular plain English word versions of functions, which
> I find easier to type, read and edit. Currently without defining such
> a handy name, I have to transform the code to this:
>
> mu bar =<<foo zot
>
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m bbind = (=<<)

I'm -1 on the *name* `bind`, because as others have mentioned, I feel bind
has the same type as (>>=).

That said, I'm +1 on the *idea* - if we can find a better name. `joinMap`
doesn't seem too bad, as was recently suggested, but I'll settle on
anything other than `bind`

-- ocharles

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

Joseph Abrahamson
I’ll clarify my earlier note: I’m +1 on the idea alone.

The name bind seems contestable (so -1) and I feel ~0 on joinMap. It sounds a bit too much like flatMap which I really dislike, although it’s at least much more accurate.



On Wed, Dec 10, 2014 at 11:02 AM, David Feuer <[hidden email]> wrote:

joinMap looks to me like the best name, because it does just what it says on the box:

join . fmap f $ m
= (m >>= return . f) >>= id --Functor/Monad law
= m >>= (\x -> return (f x) >>= id) --associativity
= m >>= (\x -> f x) --left identity
= m >>= f --eta reduction
= f =<< m

Christopher Done <[hidden email]> writes:

> Is this defined anywhere in base, and if not could it be placed in
> Control.Monad? I often find myself writing:
>
> fmap (mu bar)
>      (foo zot)
>
> Then I decide to change the type of x, so instead I want to just
> write:
>
> bind (mu bar)
>      (foo zot)
>
> Which is just like fmap but the function can run in the
> monad. Similar to traverse:
>
> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
>
> As someone who isn’t a fan of operators, I generally am appreciative
> of alternative regular plain English word versions of functions, which
> I find easier to type, read and edit. Currently without defining such
> a handy name, I have to transform the code to this:
>
> mu bar =<<foo zot
>
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m bbind = (=<<)

I'm -1 on the *name* `bind`, because as others have mentioned, I feel bind
has the same type as (>>=).

That said, I'm +1 on the *idea* - if we can find a better name. `joinMap`
doesn't seem too bad, as was recently suggested, but I'll settle on
anything other than `bind`

-- ocharles

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: bind :: Monad m => (a -> m b) -> m a -> m b

John Lato-2
In reply to this post by David Feuer

I don't really understand why people want this. What's wrong with (=<<) ?  I kind of feel like a named function should be no longer than that.

I don't object, especially if others think it's useful (and many clearly do), but I guess it's not to my taste.


On 08:02, Wed, Dec 10, 2014 David Feuer <[hidden email]> wrote:

joinMap looks to me like the best name, because it does just what it says on the box:

join . fmap f $ m
= (m >>= return . f) >>= id --Functor/Monad law
= m >>= (\x -> return (f x) >>= id) --associativity
= m >>= (\x -> f x) --left identity
= m >>= f --eta reduction
= f =<< m

Christopher Done <[hidden email]> writes:

> Is this defined anywhere in base, and if not could it be placed in
> Control.Monad? I often find myself writing:
>
> fmap (mu bar)
>      (foo zot)
>
> Then I decide to change the type of x, so instead I want to just
> write:
>
> bind (mu bar)
>      (foo zot)
>
> Which is just like fmap but the function can run in the
> monad. Similar to traverse:
>
> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
>
> As someone who isn’t a fan of operators, I generally am appreciative
> of alternative regular plain English word versions of functions, which
> I find easier to type, read and edit. Currently without defining such
> a handy name, I have to transform the code to this:
>
> mu bar =<<foo zot
>
> The name for this function is a no-brainer:
>
> bind :: Monad m => (a -> m b) -> m a -> m bbind = (=<<)

I'm -1 on the *name* `bind`, because as others have mentioned, I feel bind
has the same type as (>>=).

That said, I'm +1 on the *idea* - if we can find a better name. `joinMap`
doesn't seem too bad, as was recently suggested, but I'll settle on
anything other than `bind`

-- ocharles

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
12