Moving basic functions
dluposchainsky at googlemail.com
Wed Mar 13 10:58:41 CET 2013
Hello GHC HQ, hello mailing list,
there are a couple of basic functions that I think aren't where
they should be.
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.
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
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.
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.
As these are quite small changes I think 2 weeks should be a
sufficiently long discussion period.
More information about the Libraries