Commit eb3661f2 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Re-export `<$>` from Prelude (#10113)

Whether to re-export the `<$>` non-method operator from `Prelude` wasn't
explicitly covered in the original AMP proposal[1], but it turns out that
not doing so forces most code that makes use of applicatives to import
`Data.Functor` or `Control.Applicative` just to get that operator into
scope.  To this end, it was proposed to add `<$>` to Prelude as well[2].

The down-side is that this increases the amount of redundant-import
warnings triggered, as well as the relatively minor issue of stealing
the `<$>` operator from the default namespace for good (although at this
point `<$>` is supposed to be ubiquitous anyway due to `Applicative`
being implicitly required into the next Haskell Report)

 [1]: https://wiki.haskell.org/Functor-Applicative-Monad_Proposal
 [2]: http://thread.gmane.org/gmane.comp.lang.haskell.libraries/24161

Reviewed By: austin, ekmett

Differential Revision: https://phabricator.haskell.org/D680
parent 1965202f
......@@ -47,8 +47,6 @@ import Data.Foldable ( Foldable(..) )
import Data.Traversable ( Traversable(..) )
import Data.Monoid ( mappend )
import Control.Applicative hiding (empty)
#else
import Control.Applicative ((<$>))
#endif
{-
......
......@@ -91,7 +91,9 @@ import Maybes
import Util
import ApiAnnotation
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative ((<$>))
#endif
import Control.Monad
import Text.ParserCombinators.ReadP as ReadP
......
......@@ -49,8 +49,8 @@ import Name
import Util
import Bag
import Pair
import Control.Applicative
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative
import Data.Traversable (traverse, sequenceA)
#endif
import qualified Data.Data as Data
......
......@@ -58,7 +58,9 @@ import Module
import State
import Util
import Var
#if __GLASGOW_HASKELL__ < 709
import MonadUtils
#endif
import Outputable
import Lexeme
import FastString
......
......@@ -101,8 +101,8 @@ import Unique
import Pair
import SrcLoc
import PrelNames ( funTyConKey, eqPrimTyConKey, eqReprPrimTyConKey )
import Control.Applicative hiding ( empty )
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative hiding ( empty )
import Data.Traversable (traverse, sequenceA)
#endif
import FastString
......
......@@ -34,6 +34,7 @@ import Control.Applicative
import Control.Monad
import Control.Monad.Fix
import Control.Monad.IO.Class
import Prelude -- avoid redundant import warning due to AMP
-------------------------------------------------------------------------------
-- Lift combinators
......
......@@ -10,8 +10,8 @@ module Pair ( Pair(..), unPair, toPair, swap ) where
#include "HsVersions.h"
import Outputable
import Control.Applicative
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative
import Data.Foldable
import Data.Monoid
import Data.Traversable
......
......@@ -16,7 +16,7 @@ import FastString
import Outputable
import Control.Applicative
import Prelude -- avoid redundant import warning due to AMP
-- |Convert a vectorised expression such that it computes the non-vectorised equivalent of its
-- value.
......
......@@ -44,7 +44,9 @@ import Outputable
import FastString
import DynFlags
import Util
#if __GLASGOW_HASKELL__ < 709
import MonadUtils
#endif
import Control.Monad
import Data.Maybe
......
......@@ -17,7 +17,7 @@ import TyCon
import Control.Monad
import Control.Applicative
import Data.Maybe
import Prelude -- avoid redundant import warning due to AMP
-- |Vectorise a type constructor. Unless there is a vectorised version (stripped of embedded
-- parallel arrays), the vectorised version is the same as the original.
......
......@@ -25,7 +25,7 @@ import BasicTypes (Arity)
import FastString
import Control.Monad
import Control.Applicative
import Prelude -- avoid redundant import warning due to AMP
-- Inline ---------------------------------------------------------------------
......
......@@ -24,7 +24,7 @@ import VarEnv
import Id
import FastString
import Control.Applicative
import Prelude -- avoid redundant import warning due to AMP
-- Binders ----------------------------------------------------------------------------------------
......
......@@ -70,7 +70,7 @@ module Prelude (
Monoid(mempty, mappend, mconcat),
-- ** Monads and functors
Functor(fmap),
Functor(fmap), (<$>),
Applicative(pure, (<*>), (*>), (<*)),
Monad((>>=), (>>), return, fail),
mapM_, sequence_, (=<<),
......@@ -158,6 +158,7 @@ import System.IO.Error
import Data.List
import Data.Either
import Data.Foldable ( Foldable(..) )
import Data.Functor ( (<$>) )
import Data.Maybe
import Data.Traversable ( Traversable(..) )
import Data.Tuple
......
import Control.Applicative
main = show <$> pure 1 >>= print
main = (pure 1 >>= print) <**> pure show
import Control.Applicative ( (<$>) )
import Control.Applicative ( (<**>) )
......@@ -4,5 +4,5 @@
module T2993 where
foo b a = a <$> b . b
foo b a = a <**> b . b
T2993.hs:7:13:
Not in scope: ‘<$>’
Not in scope: ‘<**>’
Perhaps you meant ‘<*>’ (imported from Prelude)
"DataConI Ghci1.Some (ForallT [KindedTV a_1627391548 StarT] [] (AppT (AppT ArrowT (VarT a_1627391548)) (AppT (ConT Ghci1.Option) (VarT a_1627391548)))) Ghci1.Option (Fixity 9 InfixL)"
"DataConI Ghci1.Some (ForallT [KindedTV a_1627391549 StarT] [] (AppT (AppT ArrowT (VarT a_1627391549)) (AppT (ConT Ghci1.Option) (VarT a_1627391549)))) Ghci1.Option (Fixity 9 InfixL)"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment