summaryrefslogtreecommitdiff
path: root/libraries/base
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 /libraries/base
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.
Diffstat (limited to 'libraries/base')
-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
4 files changed, 4 insertions, 3 deletions
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_, (=<<),