Moving basic functions

Johan Tibell johan.tibell at gmail.com
Wed Mar 13 16:39:39 CET 2013


On Wed, Mar 13, 2013 at 2:58 AM, David Luposchainsky <
dluposchainsky at googlemail.com> wrote:

> 1. void is currently in Control.Monad. However, it is defined
>    only in terms of fmap (and therefore only has a Functor
>    constraint). Although this function is often used in a
>    monadic setting as ">> return ()", I really don't think
>    Control.Monad is the right place for it.
>

We could reexported the function in both places so we don't have to break
code that depends on its current location.


> 2. a) swap is the only function from Data.Tuple that is not
>       exported to Prelude. On #haskell, people are sometimes
>       even surprised there /is/ a Data.Tuple, and redefine
>       their own version of swap at need. I therefore suggest
>       including Data.Tuple.swap in the Prelude.
>
>       The obvious downside of this change would of course be
>       that it breaks code if there is a top-level user-defined
>       version of it. Fixing this is of course trivial, but
>       necessary.
>

I don't think we should add any more functions to the Prelude. It's a
module that's automatically put into scope into every module (unless you
explicitly use NoImplicitPrelude). Putting things in a global namespace
like that is bad.


>    b) A related suggestion would be the addition of an
>       irrefutable swap, (swap'?), defined as
>       "swap ~(a,b) = (b,a)", and its addition to Prelude for
>       the same reasons.
>

Add it to Data.Tuple.


> 3. $>, a flipped version of <$, currently resides in
>    Control.Comonad, but should be in Data.Functor. Applicative
>    has <* and *>, Monad has >>= and =<<, and I personally keep
>    redefining (or specifically importing) $> quite often, and I
>    don't think I'm the only one.
>

Makes sense to me.


> As these are quite small changes I think 2 weeks should be a
> sufficiently long discussion period.
>

Adding things to the Prelude is not a small thing! :)

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130313/44961044/attachment.htm>


More information about the Libraries mailing list