summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Lyubenov <georgi.lyubenov@tweag.io>2022-06-14 13:06:38 +0300
committerGeorgi Lyubenov <georgi.lyubenov@tweag.io>2022-09-08 17:14:36 +0300
commit77209ab32aee6f58504b303fdea2df69f5a71027 (patch)
tree4115353be46d258f8b4245072dc84ce06c18f289
parent7918265d53db963bfd3dd529b1063fb844549733 (diff)
downloadhaskell-77209ab32aee6f58504b303fdea2df69f5a71027.tar.gz
Export liftA2 from Prelude
Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details.
-rw-r--r--compiler/GHC/Hs/Doc.hs4
-rw-r--r--compiler/GHC/Types/SrcLoc.hs4
-rw-r--r--compiler/GHC/Utils/Misc.hs4
-rw-r--r--compiler/GHC/Utils/Monad.hs2
-rw-r--r--libraries/base/Data/Complex.hs1
-rw-r--r--libraries/base/Data/List/NonEmpty.hs2
-rw-r--r--libraries/base/Data/Semigroup.hs2
-rw-r--r--libraries/base/Prelude.hs2
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Lib.hs4
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs4
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs4
11 files changed, 17 insertions, 16 deletions
diff --git a/compiler/GHC/Hs/Doc.hs b/compiler/GHC/Hs/Doc.hs
index 209f9608eb..39d477be52 100644
--- a/compiler/GHC/Hs/Doc.hs
+++ b/compiler/GHC/Hs/Doc.hs
@@ -26,7 +26,7 @@ module GHC.Hs.Doc
, emptyDocs
) where
-import GHC.Prelude
+import GHC.Prelude hiding (Applicative(..))
import GHC.Utils.Binary
import GHC.Types.Name
@@ -38,7 +38,7 @@ import GHC.Types.Avail
import GHC.Types.Name.Set
import GHC.Driver.Flags
-import Control.Applicative (liftA2)
+import Control.Applicative (Applicative(..))
import Data.Data
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
diff --git a/compiler/GHC/Types/SrcLoc.hs b/compiler/GHC/Types/SrcLoc.hs
index 306fde89fa..3f68db0c30 100644
--- a/compiler/GHC/Types/SrcLoc.hs
+++ b/compiler/GHC/Types/SrcLoc.hs
@@ -115,7 +115,7 @@ module GHC.Types.SrcLoc (
) where
-import GHC.Prelude
+import GHC.Prelude hiding (Applicative(..))
import GHC.Utils.Misc
import GHC.Utils.Json
@@ -125,7 +125,7 @@ import GHC.Data.FastString
import qualified GHC.Data.Strict as Strict
import Control.DeepSeq
-import Control.Applicative (liftA2)
+import Control.Applicative (Applicative(..))
import Data.Data
import Data.List (sortBy, intercalate)
import Data.Function (on)
diff --git a/compiler/GHC/Utils/Misc.hs b/compiler/GHC/Utils/Misc.hs
index 3824f4ad5a..0ddf057ffc 100644
--- a/compiler/GHC/Utils/Misc.hs
+++ b/compiler/GHC/Utils/Misc.hs
@@ -127,7 +127,7 @@ module GHC.Utils.Misc (
HasDebugCallStack,
) where
-import GHC.Prelude
+import GHC.Prelude hiding (Applicative(..))
import GHC.Utils.Exception
import GHC.Utils.Panic.Plain
@@ -141,7 +141,7 @@ import Data.List.NonEmpty ( NonEmpty(..) )
import GHC.Exts
import GHC.Stack (HasCallStack)
-import Control.Applicative ( liftA2 )
+import Control.Applicative (Applicative(..))
import Control.Monad ( liftM, guard )
import Control.Monad.IO.Class ( MonadIO, liftIO )
import System.IO.Error as IO ( isDoesNotExistError )
diff --git a/compiler/GHC/Utils/Monad.hs b/compiler/GHC/Utils/Monad.hs
index 3bf8737990..f9fc02b338 100644
--- a/compiler/GHC/Utils/Monad.hs
+++ b/compiler/GHC/Utils/Monad.hs
@@ -27,7 +27,7 @@ module GHC.Utils.Monad
-- Imports
-------------------------------------------------------------------------------
-import GHC.Prelude
+import GHC.Prelude hiding (Applicative(..))
import Control.Applicative
import Control.Monad
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs
index c9b8040f92..734b2fabf4 100644
--- a/libraries/base/Data/Complex.hs
+++ b/libraries/base/Data/Complex.hs
@@ -35,6 +35,7 @@ module Data.Complex
) where
+import Prelude hiding (Applicative(..))
import GHC.Base (Applicative (..))
import GHC.Generics (Generic, Generic1)
import GHC.Float (Floating(..))
diff --git a/libraries/base/Data/List/NonEmpty.hs b/libraries/base/Data/List/NonEmpty.hs
index 03f631a2a7..6a31569bbb 100644
--- a/libraries/base/Data/List/NonEmpty.hs
+++ b/libraries/base/Data/List/NonEmpty.hs
@@ -102,7 +102,7 @@ import Prelude hiding (break, cycle, drop, dropWhile,
last, length, map, repeat, reverse,
scanl, scanl1, scanr, scanr1, span,
splitAt, tail, take, takeWhile,
- unzip, zip, zipWith, (!!))
+ unzip, zip, zipWith, (!!), Applicative(..))
import qualified Prelude
import Control.Applicative (Applicative (..), Alternative (many))
diff --git a/libraries/base/Data/Semigroup.hs b/libraries/base/Data/Semigroup.hs
index 08040dfea8..256f2761fd 100644
--- a/libraries/base/Data/Semigroup.hs
+++ b/libraries/base/Data/Semigroup.hs
@@ -98,7 +98,7 @@ module Data.Semigroup (
, ArgMax
) where
-import Prelude hiding (foldr1)
+import Prelude hiding (foldr1, Applicative(..))
import GHC.Base (Semigroup(..))
diff --git a/libraries/base/Prelude.hs b/libraries/base/Prelude.hs
index 2e21888abc..1309c0969d 100644
--- a/libraries/base/Prelude.hs
+++ b/libraries/base/Prelude.hs
@@ -73,7 +73,7 @@ module Prelude (
-- ** Monads and functors
Functor(fmap, (<$)), (<$>),
- Applicative(pure, (<*>), (*>), (<*)),
+ Applicative(pure, (<*>), (*>), (<*), liftA2),
Monad((>>=), (>>), return),
MonadFail(fail),
mapM_, sequence_, (=<<),
diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib.hs b/libraries/template-haskell/Language/Haskell/TH/Lib.hs
index 8e8e41df2f..e052818c0b 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Lib.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Lib.hs
@@ -178,10 +178,10 @@ import Language.Haskell.TH.Lib.Internal hiding
import qualified Language.Haskell.TH.Lib.Internal as Internal
import Language.Haskell.TH.Syntax
-import Control.Applicative ( liftA2 )
+import Control.Applicative (Applicative(..))
import Foreign.ForeignPtr
import Data.Word
-import Prelude
+import Prelude hiding (Applicative(..))
-- All definitions below represent the "old" API, since their definitions are
-- different in Language.Haskell.TH.Lib.Internal. Please think carefully before
diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
index 5d2a32d761..e95a449e1d 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
@@ -20,12 +20,12 @@ module Language.Haskell.TH.Lib.Internal where
import Language.Haskell.TH.Syntax hiding (Role, InjectivityAnn)
import qualified Language.Haskell.TH.Syntax as TH
-import Control.Applicative(liftA, liftA2)
+import Control.Applicative(liftA, Applicative(..))
import qualified Data.Kind as Kind (Type)
import Data.Word( Word8 )
import Data.List.NonEmpty ( NonEmpty(..) )
import GHC.Exts (TYPE)
-import Prelude
+import Prelude hiding (Applicative(..))
----------------------------------------------------------
-- * Type synonyms
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 48db744f72..c719541074 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -39,7 +39,7 @@ import GHC.IO.Unsafe ( unsafeDupableInterleaveIO )
import Control.Monad (liftM)
import Control.Monad.IO.Class (MonadIO (..))
import Control.Monad.Fix (MonadFix (..))
-import Control.Applicative (liftA2)
+import Control.Applicative (Applicative(..))
import Control.Exception (BlockedIndefinitelyOnMVar (..), catch, throwIO)
import Control.Exception.Base (FixIOException (..))
import Control.Concurrent.MVar (newEmptyMVar, readMVar, putMVar)
@@ -60,7 +60,7 @@ import GHC.Lexeme ( startsVarSym, startsVarId )
import GHC.ForeignSrcLang.Type
import Language.Haskell.TH.LanguageExtensions
import Numeric.Natural
-import Prelude
+import Prelude hiding (Applicative(..))
import Foreign.ForeignPtr
import Foreign.C.String
import Foreign.C.Types