Commit feac0a3b authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Reexport Semigroup's <> operator from Prelude (#14191)

This completes the 2nd phase of the Semigroup=>Monoid Proposal (SMP)
initiated in 8ae263ce.

This updates a couple submodules to address <> naming clashes.
parent 9aa73892
{-# LANGUAGE CPP #-}
-- | Custom GHC "Prelude"
--
-- This module serves as a replacement for the "Prelude" module
......@@ -6,4 +8,13 @@
--
module GhcPrelude (module X) where
-- We export the 'Semigroup' class but w/o the (<>) operator to avoid
-- clashing with the (Outputable.<>) operator which is heavily used
-- through GHC's code-base.
#if MIN_VERSION_base(4,11,0)
import Prelude as X hiding ((<>))
#else
import Prelude as X
import Data.Semigroup as X (Semigroup)
#endif
......@@ -102,6 +102,7 @@ import qualified Data.Map as M
import Data.Time.LocalTime ( getZonedTime )
import Data.Time.Format ( formatTime, defaultTimeLocale )
import Data.Version ( showVersion )
import Prelude hiding ((<>))
import Exception hiding (catch)
import Foreign hiding (void)
......
......@@ -27,7 +27,7 @@ import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Maybe
import Data.Time
import Prelude hiding (mod)
import Prelude hiding (mod,(<>))
import System.Directory
import qualified CoreUtils
......
......@@ -55,6 +55,7 @@ import Data.Time
import System.Environment
import System.IO
import Control.Monad
import Prelude hiding ((<>))
import System.Console.Haskeline (CompletionFunc, InputT)
import qualified System.Console.Haskeline as Haskeline
......
......@@ -809,7 +809,7 @@ dumpFastStringStats dflags = do
-- the "z-encoded" total.
putMsg dflags msg
where
x `pcntOf` y = int ((x * 100) `quot` y) <> char '%'
x `pcntOf` y = int ((x * 100) `quot` y) Outputable.<> char '%'
countFS :: Int -> Int -> Int -> [[FastString]] -> (Int, Int, Int)
countFS entries longest has_z [] = (entries, longest, has_z)
......
......@@ -67,7 +67,7 @@ module Prelude (
fromIntegral, realToFrac,
-- ** Semigroups and Monoids
Semigroup, -- TODO: export (<>)
Semigroup((<>)),
Monoid(mempty, mappend, mconcat),
-- ** Monads and functors
......
......@@ -11,7 +11,7 @@
* Add `Semigroup` instance for `EventLifetime`.
* Make `Semigroup` a superclass of `Monoid`;
export `Semigroup` from `Prelude`; remove `Monoid` reexport
export `Semigroup((<>))` from `Prelude`; remove `Monoid` reexport
from `Data.Semigroup` (#14191).
* Generalise `instance Monoid a => Monoid (Maybe a)` to
......
Subproject commit 6414704b892a6dc56a1b17e3a530d777b70f56ae
Subproject commit c07e4848e1b4458265e30cfb6265f9b6bd2bf053
Subproject commit 56bc78e2c2cfcc850f6fec87fe79743750d4c8b4
Subproject commit 445e92dd7508978caba5563c1e79b2758dff4767
......@@ -14,6 +14,7 @@ import Data.Char ( toLower, chr)
import GHC.Show ( showMultiLineString )
import GHC.Lexeme( startsVarSym )
import Data.Ratio ( numerator, denominator )
import Prelude hiding ((<>))
nestDepth :: Int
nestDepth = 4
......
......@@ -41,6 +41,7 @@ import qualified Text.PrettyPrint as HPJ
import Control.Monad (liftM, liftM2, ap)
import Language.Haskell.TH.Lib.Map ( Map )
import qualified Language.Haskell.TH.Lib.Map as Map ( lookup, insert, empty )
import Prelude hiding ((<>))
infixl 6 <>
infixl 6 <+>
......
Subproject commit 1707aa5f2ad5c254c45ac9ffcac749e4d6b67a6e
Subproject commit 2d88a0a3e8e3bb79260e5c8f61dd6c447f61c5f5
......@@ -3,7 +3,7 @@
module Main where
import Control.Applicative
import Text.PrettyPrint
import Text.PrettyPrint as PP
(a:b:c:d:e:f:g:h:_) = map (\c -> doc [c]) ['a'..]
......@@ -64,7 +64,7 @@ instance Monad M where
(Nothing,Nothing) -> (Nothing, b)
(Just d, Nothing) -> (Just d, b)
(Nothing, Just d) -> (Just d, b)
(Just d1, Just d2) -> (Just (maybeParen p (d1 <> semi <+> d2)), b)
(Just d1, Just d2) -> (Just (maybeParen p (d1 PP.<> semi <+> d2)), b)
doc :: String -> M ()
doc d = M $ \_ -> (Just (text d), ())
......@@ -2,7 +2,7 @@
module Main where
import Control.Applicative
import Text.PrettyPrint
import Text.PrettyPrint as PP
(a:b:c:d:e:f:g:h:_) = map (\c -> doc [c]) ['a'..]
......@@ -175,7 +175,7 @@ instance Monad M where
(Nothing,Nothing) -> (Nothing, b)
(Just d, Nothing) -> (Just d, b)
(Nothing, Just d) -> (Just d, b)
(Just d1, Just d2) -> (Just (maybeParen p (d1 <> semi <+> d2)), b)
(Just d1, Just d2) -> (Just (maybeParen p (d1 PP.<> semi <+> d2)), b)
doc :: String -> M ()
doc d = M $ \_ -> (Just (text d), ())
......@@ -172,7 +172,7 @@ main = do
case lintExpr dflags [f,scrutf,scruta] e of
Just msg -> putMsg dflags (msg $$ text "in" <+> text n)
Nothing -> return ()
putMsg dflags (text n <> char ':')
putMsg dflags (text n Outputable.<> char ':')
-- liftIO $ putMsg dflags (ppr e)
let e' = callArityRHS e
let bndrs = nonDetEltsUniqSet (allBoundIds e')
......
module T10618 where
foo = Just $ Nothing <> Nothing
foo = Just $ Nothing <|> Nothing
T10618.hs:3:22: error:
• Variable not in scope: (<>) :: Maybe (Maybe a0) -> Maybe a1 -> t
• Variable not in scope: (<|>) :: Maybe (Maybe a0) -> Maybe a1 -> t
• Perhaps you meant one of these:
‘<$>’ (imported from Prelude), ‘*>’ (imported from Prelude),
‘<$’ (imported from Prelude)
‘<$>’ (imported from Prelude), ‘<*>’ (imported from Prelude),
‘<>’ (imported from Prelude)
Subproject commit 2f6c11305cca9f50833b99dac729ce76e46aa235
Subproject commit 0a64b5cdc051c47b24151b8839ae9067f06d8d0d
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