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(..) ) ...@@ -47,8 +47,6 @@ import Data.Foldable ( Foldable(..) )
import Data.Traversable ( Traversable(..) ) import Data.Traversable ( Traversable(..) )
import Data.Monoid ( mappend ) import Data.Monoid ( mappend )
import Control.Applicative hiding (empty) import Control.Applicative hiding (empty)
#else
import Control.Applicative ((<$>))
#endif #endif
{- {-
......
...@@ -91,7 +91,9 @@ import Maybes ...@@ -91,7 +91,9 @@ import Maybes
import Util import Util
import ApiAnnotation import ApiAnnotation
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
#endif
import Control.Monad import Control.Monad
import Text.ParserCombinators.ReadP as ReadP import Text.ParserCombinators.ReadP as ReadP
......
...@@ -49,8 +49,8 @@ import Name ...@@ -49,8 +49,8 @@ import Name
import Util import Util
import Bag import Bag
import Pair import Pair
import Control.Applicative
#if __GLASGOW_HASKELL__ < 709 #if __GLASGOW_HASKELL__ < 709
import Control.Applicative
import Data.Traversable (traverse, sequenceA) import Data.Traversable (traverse, sequenceA)
#endif #endif
import qualified Data.Data as Data import qualified Data.Data as Data
......
...@@ -58,7 +58,9 @@ import Module ...@@ -58,7 +58,9 @@ import Module
import State import State
import Util import Util
import Var import Var
#if __GLASGOW_HASKELL__ < 709
import MonadUtils import MonadUtils
#endif
import Outputable import Outputable
import Lexeme import Lexeme
import FastString import FastString
......
...@@ -101,8 +101,8 @@ import Unique ...@@ -101,8 +101,8 @@ import Unique
import Pair import Pair
import SrcLoc import SrcLoc
import PrelNames ( funTyConKey, eqPrimTyConKey, eqReprPrimTyConKey ) import PrelNames ( funTyConKey, eqPrimTyConKey, eqReprPrimTyConKey )
import Control.Applicative hiding ( empty )
#if __GLASGOW_HASKELL__ < 709 #if __GLASGOW_HASKELL__ < 709
import Control.Applicative hiding ( empty )
import Data.Traversable (traverse, sequenceA) import Data.Traversable (traverse, sequenceA)
#endif #endif
import FastString import FastString
......
...@@ -34,6 +34,7 @@ import Control.Applicative ...@@ -34,6 +34,7 @@ import Control.Applicative
import Control.Monad import Control.Monad
import Control.Monad.Fix import Control.Monad.Fix
import Control.Monad.IO.Class import Control.Monad.IO.Class
import Prelude -- avoid redundant import warning due to AMP
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Lift combinators -- Lift combinators
......
...@@ -10,8 +10,8 @@ module Pair ( Pair(..), unPair, toPair, swap ) where ...@@ -10,8 +10,8 @@ module Pair ( Pair(..), unPair, toPair, swap ) where
#include "HsVersions.h" #include "HsVersions.h"
import Outputable import Outputable
import Control.Applicative
#if __GLASGOW_HASKELL__ < 709 #if __GLASGOW_HASKELL__ < 709
import Control.Applicative
import Data.Foldable import Data.Foldable
import Data.Monoid import Data.Monoid
import Data.Traversable import Data.Traversable
......
...@@ -16,7 +16,7 @@ import FastString ...@@ -16,7 +16,7 @@ import FastString
import Outputable import Outputable
import Control.Applicative 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 -- |Convert a vectorised expression such that it computes the non-vectorised equivalent of its
-- value. -- value.
......
...@@ -44,7 +44,9 @@ import Outputable ...@@ -44,7 +44,9 @@ import Outputable
import FastString import FastString
import DynFlags import DynFlags
import Util import Util
#if __GLASGOW_HASKELL__ < 709
import MonadUtils import MonadUtils
#endif
import Control.Monad import Control.Monad
import Data.Maybe import Data.Maybe
......
...@@ -17,7 +17,7 @@ import TyCon ...@@ -17,7 +17,7 @@ import TyCon
import Control.Monad import Control.Monad
import Control.Applicative import Control.Applicative
import Data.Maybe 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 -- |Vectorise a type constructor. Unless there is a vectorised version (stripped of embedded
-- parallel arrays), the vectorised version is the same as the original. -- parallel arrays), the vectorised version is the same as the original.
......
...@@ -25,7 +25,7 @@ import BasicTypes (Arity) ...@@ -25,7 +25,7 @@ import BasicTypes (Arity)
import FastString import FastString
import Control.Monad import Control.Monad
import Control.Applicative import Control.Applicative
import Prelude -- avoid redundant import warning due to AMP
-- Inline --------------------------------------------------------------------- -- Inline ---------------------------------------------------------------------
......
...@@ -24,7 +24,7 @@ import VarEnv ...@@ -24,7 +24,7 @@ import VarEnv
import Id import Id
import FastString import FastString
import Control.Applicative import Control.Applicative
import Prelude -- avoid redundant import warning due to AMP
-- Binders ---------------------------------------------------------------------------------------- -- Binders ----------------------------------------------------------------------------------------
......
...@@ -70,7 +70,7 @@ module Prelude ( ...@@ -70,7 +70,7 @@ module Prelude (
Monoid(mempty, mappend, mconcat), Monoid(mempty, mappend, mconcat),
-- ** Monads and functors -- ** Monads and functors
Functor(fmap), Functor(fmap), (<$>),
Applicative(pure, (<*>), (*>), (<*)), Applicative(pure, (<*>), (*>), (<*)),
Monad((>>=), (>>), return, fail), Monad((>>=), (>>), return, fail),
mapM_, sequence_, (=<<), mapM_, sequence_, (=<<),
...@@ -158,6 +158,7 @@ import System.IO.Error ...@@ -158,6 +158,7 @@ import System.IO.Error
import Data.List import Data.List
import Data.Either import Data.Either
import Data.Foldable ( Foldable(..) ) import Data.Foldable ( Foldable(..) )
import Data.Functor ( (<$>) )
import Data.Maybe import Data.Maybe
import Data.Traversable ( Traversable(..) ) import Data.Traversable ( Traversable(..) )
import Data.Tuple import Data.Tuple
......
import Control.Applicative import Control.Applicative
main = show <$> pure 1 >>= print main = (pure 1 >>= print) <**> pure show
import Control.Applicative ( (<$>) ) import Control.Applicative ( (<**>) )
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
module T2993 where module T2993 where
foo b a = a <$> b . b foo b a = a <**> b . b
T2993.hs:7:13: T2993.hs:7:13:
Not in scope: ‘<$>’ Not in scope: ‘<**>’
Perhaps you meant ‘<*>’ (imported from Prelude) 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