Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • nikshalark/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • gulin.serge/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • MTaimoorZaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • fp/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
640 results
Show changes
Commits on Source (5)
Showing
with 339 additions and 336 deletions
......@@ -4,7 +4,7 @@ module GHC.Data.Bool
)
where
import Prelude
import GHC.Prelude.Basic
data OverridingBool
= Auto
......
......@@ -13,7 +13,7 @@ module GHC.Data.FastMutInt(
atomicFetchAddFastMut
) where
import GHC.Prelude
import GHC.Prelude.Basic
import GHC.Base
......
......@@ -109,7 +109,7 @@ module GHC.Data.FastString
lengthPS
) where
import GHC.Prelude
import GHC.Prelude.Basic
import GHC.Data.FastString.Type
......
......@@ -52,7 +52,7 @@ module GHC.Data.FastString.Type
) where
import Prelude
import GHC.Prelude.Basic
import Control.DeepSeq
import Data.ByteString (ByteString)
......
......@@ -2,6 +2,8 @@ module GHC.Driver.Config.StgToCmm
( initStgToCmmConfig
) where
import GHC.Prelude.Basic
import GHC.StgToCmm.Config
import GHC.Driver.Backend
......@@ -12,9 +14,6 @@ import GHC.Utils.Error
import GHC.Unit.Module
import GHC.Utils.Outputable
import Data.Maybe
import Prelude
initStgToCmmConfig :: DynFlags -> Module -> StgToCmmConfig
initStgToCmmConfig dflags mod = StgToCmmConfig
-- settings
......
......@@ -13,11 +13,8 @@
-- * Explicitly imports GHC.Prelude
module GHC.Prelude
(module X
,Applicative (..)
,module Bits
(module GHC.Prelude
,module GHC.Utils.Trace
,shiftL, shiftR
) where
......@@ -49,9 +46,7 @@ NoImplicitPrelude. There are two motivations for this:
extensions.
-}
import Prelude as X hiding ((<>), Applicative(..))
import Control.Applicative (Applicative(..))
import Data.Foldable as X (foldl')
import GHC.Prelude.Basic as GHC.Prelude
import {-# SOURCE #-} GHC.Utils.Trace
( pprTrace
......@@ -64,52 +59,3 @@ import {-# SOURCE #-} GHC.Utils.Trace
, warnPprTrace
, pprTraceUserWarning
)
#if MIN_VERSION_base(4,16,0)
import GHC.Bits as Bits hiding (shiftL, shiftR)
# if defined(DEBUG)
import qualified GHC.Bits as Bits (shiftL, shiftR)
# endif
#else
--base <4.15
import Data.Bits as Bits hiding (shiftL, shiftR)
# if defined(DEBUG)
import qualified Data.Bits as Bits (shiftL, shiftR)
# endif
#endif
{- Note [Default to unsafe shifts inside GHC]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The safe shifts can introduce branches which come
at the cost of performance. We still want the additional
debugability for debug builds. So we define it as one or the
other depending on the DEBUG setting.
Why do we then continue on to re-export the rest of Data.Bits?
If we would not what is likely to happen is:
* Someone imports Data.Bits, uses xor. Things are fine.
* They add a shift and get an ambiguous definition error.
* The are puzzled for a bit.
* They either:
+ Remove the import of Data.Bits and get an error because xor is not in scope.
+ Add the hiding clause to the Data.Bits import for the shifts.
Either is quite annoying. Simply re-exporting all of Data.Bits avoids this
making for a smoother developer experience. At the cost of having a few more
names in scope at all time. But that seems like a fair tradeoff.
See also #19618
-}
-- We always want the Data.Bits method to show up for rules etc.
{-# INLINE shiftL #-}
{-# INLINE shiftR #-}
shiftL, shiftR :: Bits.Bits a => a -> Int -> a
#if defined(DEBUG)
shiftL = Bits.shiftL
shiftR = Bits.shiftR
#else
shiftL = Bits.unsafeShiftL
shiftR = Bits.unsafeShiftR
#endif
{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK not-home #-}
{-# OPTIONS_GHC -O2 #-} -- See Note [-O2 Prelude]
-- | Custom minimal GHC "Prelude"
--
-- This module serves as a replacement for the "Prelude" module
-- and abstracts over differences between the bootstrapping
-- GHC version, and may also provide a common default vocabulary.
-- Every module in GHC
-- * Is compiled with -XNoImplicitPrelude
-- * Explicitly imports GHC.BasicPrelude or GHC.Prelude
-- * The later provides some functionality with within ghc itself
-- like pprTrace.
module GHC.Prelude.Basic
(module X
,Applicative (..)
,module Bits
,shiftL, shiftR
) where
{- Note [-O2 Prelude]
~~~~~~~~~~~~~~~~~~~~~
There is some code in GHC that is *always* compiled with -O[2] because
of it's impact on compile time performance. Some of this code might depend
on the definitions like shiftL being defined here being performant.
So we always compile this module with -O2. It's (currently) tiny so I
have little reason to suspect this impacts overall GHC compile times
negatively.
-}
-- 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.
{-
Note [Why do we import Prelude here?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The files ghc-boot-th.cabal, ghc-boot.cabal, ghci.cabal and
ghc-heap.cabal contain the directive default-extensions:
NoImplicitPrelude. There are two motivations for this:
- Consistency with the compiler directory, which enables
NoImplicitPrelude;
- Allows loading the above dependent packages with ghc-in-ghci,
giving a smoother development experience when adding new
extensions.
-}
import Prelude as X hiding ((<>), Applicative(..))
import Control.Applicative (Applicative(..))
import Data.Foldable as X (foldl')
#if MIN_VERSION_base(4,16,0)
import GHC.Bits as Bits hiding (shiftL, shiftR)
# if defined(DEBUG)
import qualified GHC.Bits as Bits (shiftL, shiftR)
# endif
#else
--base <4.15
import Data.Bits as Bits hiding (shiftL, shiftR)
# if defined(DEBUG)
import qualified Data.Bits as Bits (shiftL, shiftR)
# endif
#endif
{- Note [Default to unsafe shifts inside GHC]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The safe shifts can introduce branches which come
at the cost of performance. We still want the additional
debugability for debug builds. So we define it as one or the
other depending on the DEBUG setting.
Why do we then continue on to re-export the rest of Data.Bits?
If we would not what is likely to happen is:
* Someone imports Data.Bits, uses xor. Things are fine.
* They add a shift and get an ambiguous definition error.
* The are puzzled for a bit.
* They either:
+ Remove the import of Data.Bits and get an error because xor is not in scope.
+ Add the hiding clause to the Data.Bits import for the shifts.
Either is quite annoying. Simply re-exporting all of Data.Bits avoids this
making for a smoother developer experience. At the cost of having a few more
names in scope at all time. But that seems like a fair tradeoff.
See also #19618
-}
-- We always want the Data.Bits method to show up for rules etc.
{-# INLINE shiftL #-}
{-# INLINE shiftR #-}
shiftL, shiftR :: Bits.Bits a => a -> Int -> a
#if defined(DEBUG)
shiftL = Bits.shiftL
shiftR = Bits.shiftR
#else
shiftL = Bits.unsafeShiftL
shiftR = Bits.unsafeShiftR
#endif
......@@ -24,7 +24,7 @@ module GHC.Utils.BufHandle (
bFlush,
) where
import GHC.Prelude
import GHC.Prelude.Basic
import GHC.Data.FastString
import GHC.Data.FastMutInt
......
......@@ -8,7 +8,7 @@ module GHC.Utils.Constants
)
where
import GHC.Prelude
import GHC.Prelude.Basic
{-
......
......@@ -8,7 +8,7 @@ module GHC.Utils.Exception
)
where
import Prelude
import GHC.Prelude.Basic
import GHC.IO (catchException)
import Control.Exception as CE hiding (assert)
......
......@@ -22,7 +22,7 @@ module GHC.Utils.Fingerprint (
getFileHash
) where
import GHC.Prelude
import GHC.Prelude.Basic
import Foreign
import GHC.IO
......
......@@ -22,7 +22,7 @@ module GHC.Utils.GlobalVars
)
where
import GHC.Prelude
import GHC.Prelude.Basic
import GHC.Conc.Sync ( sharedCAF )
......
......@@ -9,7 +9,7 @@ module GHC.Utils.IO.Unsafe
)
where
import GHC.Prelude ()
import GHC.Prelude.Basic ()
import GHC.Exts
import GHC.IO (IO(..))
......
......@@ -124,7 +124,7 @@ module GHC.Utils.Misc (
HasDebugCallStack,
) where
import GHC.Prelude hiding ( head, init, last, tail )
import GHC.Prelude.Basic hiding ( head, init, last, tail )
import GHC.Utils.Exception
import GHC.Utils.Panic.Plain
......
......@@ -6,11 +6,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-- The SDoc IsString instance requires the text function from this module.
-- Given the choice between an orphan instance and using a boot module I chose
-- the orphan instance. Mostly for performance reasons.
{-# OPTIONS_GHC -Wno-orphans #-}
{-
(c) The University of Glasgow 2006-2012
(c) The GRASP Project, Glasgow University, 1992-1998
......@@ -111,13 +106,12 @@ module GHC.Utils.Outputable (
) where
import GHC.Prelude
import GHC.Utils.Outputable.SDoc
import Language.Haskell.Syntax.Module.Name ( ModuleName(..) )
import {-# SOURCE #-} GHC.Unit.Types ( moduleName )
-- import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName )
import GHC.Prelude.Basic
import {-# SOURCE #-} GHC.Unit.Types ( Unit, Module, moduleName )
import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName )
import GHC.Utils.BufHandle (BufHandle)
import GHC.Data.FastString
......@@ -154,8 +148,77 @@ import Data.Time.Format.ISO8601
import GHC.Fingerprint
import GHC.Show ( showMultiLineString )
import GHC.Utils.Exception
-- import GHC.Exts (oneShot)
import GHC.Exts (oneShot)
{-
************************************************************************
* *
\subsection{The @PprStyle@ data type}
* *
************************************************************************
-}
data PprStyle
= PprUser PrintUnqualified Depth Coloured
-- Pretty-print in a way that will make sense to the
-- ordinary user; must be very close to Haskell
-- syntax, etc.
-- Assumes printing tidied code: non-system names are
-- printed without uniques.
| PprDump PrintUnqualified
-- For -ddump-foo; less verbose than in ppr-debug mode, but more than PprUser
-- Does not assume tidied code: non-external names
-- are printed with uniques.
| PprCode -- ^ Print code; either C or assembler
data Depth
= AllTheWay
| PartWay Int -- ^ 0 => stop
| DefaultDepth -- ^ Use 'sdocDefaultDepth' field as depth
data Coloured
= Uncoloured
| Coloured
-- -----------------------------------------------------------------------------
-- Printing original names
-- | When printing code that contains original names, we need to map the
-- original names back to something the user understands. This is the
-- purpose of the triple of functions that gets passed around
-- when rendering 'SDoc'.
data PrintUnqualified = QueryQualify {
queryQualifyName :: QueryQualifyName,
queryQualifyModule :: QueryQualifyModule,
queryQualifyPackage :: QueryQualifyPackage
}
-- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify
-- it.
type QueryQualifyName = Module -> OccName -> QualifyName
-- | For a given module, we need to know whether to print it with
-- a package name to disambiguate it.
type QueryQualifyModule = Module -> Bool
-- | For a given package, we need to know whether to print it with
-- the component id to disambiguate it.
type QueryQualifyPackage = Unit -> Bool
-- See Note [Printing original names] in GHC.Types.Name.Ppr
data QualifyName -- Given P:M.T
= NameUnqual -- It's in scope unqualified as "T"
-- OR nothing called "T" is in scope
| NameQual ModuleName -- It's in scope qualified as "X.T"
| NameNotInScope1 -- It's not in scope at all, but M.T is not bound
-- in the current scope, so we can refer to it as "M.T"
| NameNotInScope2 -- It's not in scope at all, and M.T is already bound in
-- the current scope, so we must refer to it as "P:M.T"
instance Outputable QualifyName where
ppr NameUnqual = text "NameUnqual"
......@@ -253,8 +316,85 @@ shown.
The following test decides whether or not we are actually generating
code (either C or assembly), or generating interface files.
************************************************************************
* *
\subsection{The @SDoc@ data type}
* *
************************************************************************
-}
-- | Represents a pretty-printable document.
--
-- To display an 'SDoc', use 'printSDoc', 'printSDocLn', 'bufLeftRenderSDoc',
-- or 'renderWithContext'. Avoid calling 'runSDoc' directly as it breaks the
-- abstraction layer.
newtype SDoc = SDoc' (SDocContext -> Doc)
-- See Note [The one-shot state monad trick] in GHC.Utils.Monad
{-# COMPLETE SDoc #-}
pattern SDoc :: (SDocContext -> Doc) -> SDoc
pattern SDoc m <- SDoc' m
where
SDoc m = SDoc' (oneShot m)
runSDoc :: SDoc -> (SDocContext -> Doc)
runSDoc (SDoc m) = m
data SDocContext = SDC
{ sdocStyle :: !PprStyle
, sdocColScheme :: !Col.Scheme
, sdocLastColour :: !Col.PprColour
-- ^ The most recently used colour.
-- This allows nesting colours.
, sdocShouldUseColor :: !Bool
, sdocDefaultDepth :: !Int
, sdocLineLength :: !Int
, sdocCanUseUnicode :: !Bool
-- ^ True if Unicode encoding is supported
-- and not disabled by GHC_NO_UNICODE environment variable
, sdocHexWordLiterals :: !Bool
, sdocPprDebug :: !Bool
, sdocPrintUnicodeSyntax :: !Bool
, sdocPrintCaseAsLet :: !Bool
, sdocPrintTypecheckerElaboration :: !Bool
, sdocPrintAxiomIncomps :: !Bool
, sdocPrintExplicitKinds :: !Bool
, sdocPrintExplicitCoercions :: !Bool
, sdocPrintExplicitRuntimeReps :: !Bool
, sdocPrintExplicitForalls :: !Bool
, sdocPrintPotentialInstances :: !Bool
, sdocPrintEqualityRelations :: !Bool
, sdocSuppressTicks :: !Bool
, sdocSuppressTypeSignatures :: !Bool
, sdocSuppressTypeApplications :: !Bool
, sdocSuppressIdInfo :: !Bool
, sdocSuppressCoercions :: !Bool
, sdocSuppressCoercionTypes :: !Bool
, sdocSuppressUnfoldings :: !Bool
, sdocSuppressVarKinds :: !Bool
, sdocSuppressUniques :: !Bool
, sdocSuppressModulePrefixes :: !Bool
, sdocSuppressStgExts :: !Bool
, sdocErrorSpans :: !Bool
, sdocStarIsType :: !Bool
, sdocLinearTypes :: !Bool
, sdocListTuplePuns :: !Bool
, sdocPrintTypeAbbreviations :: !Bool
, sdocUnitIdForUser :: !(FastString -> SDoc)
-- ^ Used to map UnitIds to more friendly "package-version:component"
-- strings while pretty-printing.
--
-- Use `GHC.Unit.State.pprWithUnitState` to set it. Users should never
-- have to set it to pretty-print SDocs emitted by GHC, otherwise it's a
-- bug. It's an internal field used to thread the UnitState so that the
-- Outputable instance of UnitId can use it.
--
-- See Note [Pretty-printing UnitId] in "GHC.Unit" for more details.
--
-- Note that we use `FastString` instead of `UnitId` to avoid boring
-- module inter-dependency issues.
}
instance IsString SDoc where
fromString = text
......
{-# LANGUAGE PatternSynonyms #-}
-- Having the SDoc type in it's own module allows us to export
-- trace functions from our prelude.
-- See Note [Exporting pprTrace from GHC.Prelude]
module GHC.Utils.Outputable.SDoc where
import Prelude
import GHC.Utils.Ppr.Doc
import Language.Haskell.Syntax.Module.Name.Type ( ModuleName(..) )
import qualified GHC.Utils.Ppr.Colour as Col
import {-# SOURCE #-} GHC.Unit.Types ( Unit, Module )
import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName )
import GHC.Data.FastString.Type ( FastString )
import GHC.Exts (oneShot)
{-
************************************************************************
* *
\subsection{The @SDoc@ data type}
* *
************************************************************************
-}
-- | Represents a pretty-printable document.
--
-- To display an 'SDoc', use 'printSDoc', 'printSDocLn', 'bufLeftRenderSDoc',
-- or 'renderWithContext'. Avoid calling 'runSDoc' directly as it breaks the
-- abstraction layer.
newtype SDoc = SDoc' (SDocContext -> Doc)
-- See Note [The one-shot state monad trick] in GHC.Utils.Monad
{-# COMPLETE SDoc #-}
pattern SDoc :: (SDocContext -> Doc) -> SDoc
pattern SDoc m <- SDoc' m
where
SDoc m = SDoc' (oneShot m)
runSDoc :: SDoc -> (SDocContext -> Doc)
runSDoc (SDoc m) = m
data SDocContext = SDC
{ sdocStyle :: !PprStyle
, sdocColScheme :: !Col.Scheme
, sdocLastColour :: !Col.PprColour
-- ^ The most recently used colour.
-- This allows nesting colours.
, sdocShouldUseColor :: !Bool
, sdocDefaultDepth :: !Int
, sdocLineLength :: !Int
, sdocCanUseUnicode :: !Bool
-- ^ True if Unicode encoding is supported
-- and not disabled by GHC_NO_UNICODE environment variable
, sdocHexWordLiterals :: !Bool
, sdocPprDebug :: !Bool
, sdocPrintUnicodeSyntax :: !Bool
, sdocPrintCaseAsLet :: !Bool
, sdocPrintTypecheckerElaboration :: !Bool
, sdocPrintAxiomIncomps :: !Bool
, sdocPrintExplicitKinds :: !Bool
, sdocPrintExplicitCoercions :: !Bool
, sdocPrintExplicitRuntimeReps :: !Bool
, sdocPrintExplicitForalls :: !Bool
, sdocPrintPotentialInstances :: !Bool
, sdocPrintEqualityRelations :: !Bool
, sdocSuppressTicks :: !Bool
, sdocSuppressTypeSignatures :: !Bool
, sdocSuppressTypeApplications :: !Bool
, sdocSuppressIdInfo :: !Bool
, sdocSuppressCoercions :: !Bool
, sdocSuppressCoercionTypes :: !Bool
, sdocSuppressUnfoldings :: !Bool
, sdocSuppressVarKinds :: !Bool
, sdocSuppressUniques :: !Bool
, sdocSuppressModulePrefixes :: !Bool
, sdocSuppressStgExts :: !Bool
, sdocErrorSpans :: !Bool
, sdocStarIsType :: !Bool
, sdocLinearTypes :: !Bool
, sdocListTuplePuns :: !Bool
, sdocPrintTypeAbbreviations :: !Bool
, sdocUnitIdForUser :: !(FastString -> SDoc)
-- ^ Used to map UnitIds to more friendly "package-version:component"
-- strings while pretty-printing.
--
-- Use `GHC.Unit.State.pprWithUnitState` to set it. Users should never
-- have to set it to pretty-print SDocs emitted by GHC, otherwise it's a
-- bug. It's an internal field used to thread the UnitState so that the
-- Outputable instance of UnitId can use it.
--
-- See Note [Pretty-printing UnitId] in "GHC.Unit" for more details.
--
-- Note that we use `FastString` instead of `UnitId` to avoid boring
-- module inter-dependency issues.
}
{-
************************************************************************
* *
\subsection{The @PprStyle@ data type}
* *
************************************************************************
-}
data PprStyle
= PprUser PrintUnqualified Depth Coloured
-- Pretty-print in a way that will make sense to the
-- ordinary user; must be very close to Haskell
-- syntax, etc.
-- Assumes printing tidied code: non-system names are
-- printed without uniques.
| PprDump PrintUnqualified
-- For -ddump-foo; less verbose than in ppr-debug mode, but more than PprUser
-- Does not assume tidied code: non-external names
-- are printed with uniques.
| PprCode -- ^ Print code; either C or assembler
data Depth
= AllTheWay
| PartWay Int -- ^ 0 => stop
| DefaultDepth -- ^ Use 'sdocDefaultDepth' field as depth
data Coloured
= Uncoloured
| Coloured
-- -----------------------------------------------------------------------------
-- Printing original names
-- | When printing code that contains original names, we need to map the
-- original names back to something the user understands. This is the
-- purpose of the triple of functions that gets passed around
-- when rendering 'SDoc'.
data PrintUnqualified = QueryQualify {
queryQualifyName :: QueryQualifyName,
queryQualifyModule :: QueryQualifyModule,
queryQualifyPackage :: QueryQualifyPackage
}
-- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify
-- it.
type QueryQualifyName = Module -> OccName -> QualifyName
-- | For a given module, we need to know whether to print it with
-- a package name to disambiguate it.
type QueryQualifyModule = Module -> Bool
-- | For a given package, we need to know whether to print it with
-- the component id to disambiguate it.
type QueryQualifyPackage = Unit -> Bool
-- See Note [Printing original names] in GHC.Types.Name.Ppr
data QualifyName -- Given P:M.T
= NameUnqual -- It's in scope unqualified as "T"
-- OR nothing called "T" is in scope
| NameQual ModuleName -- It's in scope qualified as "X.T"
| NameNotInScope1 -- It's not in scope at all, but M.T is not bound
-- in the current scope, so we can refer to it as "M.T"
| NameNotInScope2 -- It's not in scope at all, and M.T is already bound in
-- the current scope, so we must refer to it as "P:M.T"
\ No newline at end of file
......@@ -28,7 +28,7 @@ import GHC.Settings.Config
import GHC.Utils.Constants
import GHC.Utils.Exception as Exception
import GHC.Stack
import GHC.Prelude
import GHC.Prelude.Basic
import System.IO.Unsafe
-- | This type is very similar to 'GHC.Utils.Panic.GhcException', but it omits
......
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
-- The Doc Show instance requires the fullRender function from this module.
-- Given the choice between an orphan instance and using a boot module I chose
-- the orphan instance. Mostly for performance reasons.
{-# OPTIONS_GHC -Wno-orphans #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Utils.Ppr
......@@ -115,7 +111,7 @@ module GHC.Utils.Ppr (
) where
import GHC.Prelude hiding (error)
import GHC.Prelude.Basic hiding (error)
import GHC.Utils.BufHandle
import GHC.Data.FastString
......@@ -127,7 +123,6 @@ import Numeric (showHex)
import GHC.Base ( unpackCString#, unpackNBytes#, Int(..) )
import GHC.Ptr ( Ptr(..) )
import GHC.Utils.Ppr.Doc
-- ---------------------------------------------------------------------------
-- The Doc calculus
......@@ -211,6 +206,72 @@ infixl 6 <+>
infixl 5 $$, $+$
-- ---------------------------------------------------------------------------
-- The Doc data type
-- | The abstract type of documents.
-- A Doc represents a *set* of layouts. A Doc with
-- no occurrences of Union or NoDoc represents just one layout.
data Doc
= Empty -- empty
| NilAbove Doc -- text "" $$ x
| TextBeside !TextDetails {-# UNPACK #-} !Int Doc -- text s <> x
| Nest {-# UNPACK #-} !Int Doc -- nest k x
| Union Doc Doc -- ul `union` ur
| NoDoc -- The empty set of documents
| Beside Doc Bool Doc -- True <=> space between
| Above Doc Bool Doc -- True <=> never overlap
{-
Here are the invariants:
1) The argument of NilAbove is never Empty. Therefore
a NilAbove occupies at least two lines.
2) The argument of @TextBeside@ is never @Nest@.
3) The layouts of the two arguments of @Union@ both flatten to the same
string.
4) The arguments of @Union@ are either @TextBeside@, or @NilAbove@.
5) A @NoDoc@ may only appear on the first line of the left argument of an
union. Therefore, the right argument of an union can never be equivalent
to the empty set (@NoDoc@).
6) An empty document is always represented by @Empty@. It can't be
hidden inside a @Nest@, or a @Union@ of two @Empty@s.
7) The first line of every layout in the left argument of @Union@ is
longer than the first line of any layout in the right argument.
(1) ensures that the left argument has a first line. In view of
(3), this invariant means that the right argument must have at
least two lines.
Notice the difference between
* NoDoc (no documents)
* Empty (one empty document; no height and no width)
* text "" (a document containing the empty string;
one line high, but has no width)
-}
-- | RDoc is a "reduced GDoc", guaranteed not to have a top-level Above or Beside.
type RDoc = Doc
-- | The TextDetails data type
--
-- A TextDetails represents a fragment of text that will be
-- output at some point.
data TextDetails = Chr {-# UNPACK #-} !Char -- ^ A single Char fragment
| Str String -- ^ A whole String fragment
| PStr FastString -- a hashed string
| ZStr FastZString -- a z-encoded string
| LStr {-# UNPACK #-} !PtrString
-- a '\0'-terminated array of bytes
| RStr {-# UNPACK #-} !Int {-# UNPACK #-} !Char
-- a repeated character (e.g., ' ')
instance Show Doc where
showsPrec _ doc cont = fullRender (mode style) (lineLength style)
(ribbonsPerLine style)
......
module GHC.Utils.Ppr.Colour where
import Prelude
import GHC.Prelude.Basic
import Data.Maybe (fromMaybe)
import GHC.Data.Bool
......
-- | This module contains some ppr internals which need to live in their own
-- module to avoid module loops.
-- Avoid importing it directly and instead import GHC.Utils.Ppr instead if
-- possible.
-- See Note [Exporting pprTrace from GHC.Prelude]
module GHC.Utils.Ppr.Doc where
import Prelude
import GHC.Data.FastString.Type ( FastString, FastZString, PtrString )
-- ---------------------------------------------------------------------------
-- The Doc data type
-- | The abstract type of documents.
-- A Doc represents a *set* of layouts. A Doc with
-- no occurrences of Union or NoDoc represents just one layout.
data Doc
= Empty -- empty
| NilAbove Doc -- text "" $$ x
| TextBeside !TextDetails {-# UNPACK #-} !Int Doc -- text s <> x
| Nest {-# UNPACK #-} !Int Doc -- nest k x
| Union Doc Doc -- ul `union` ur
| NoDoc -- The empty set of documents
| Beside Doc Bool Doc -- True <=> space between
| Above Doc Bool Doc -- True <=> never overlap
{-
Here are the invariants:
1) The argument of NilAbove is never Empty. Therefore
a NilAbove occupies at least two lines.
2) The argument of @TextBeside@ is never @Nest@.
3) The layouts of the two arguments of @Union@ both flatten to the same
string.
4) The arguments of @Union@ are either @TextBeside@, or @NilAbove@.
5) A @NoDoc@ may only appear on the first line of the left argument of an
union. Therefore, the right argument of an union can never be equivalent
to the empty set (@NoDoc@).
6) An empty document is always represented by @Empty@. It can't be
hidden inside a @Nest@, or a @Union@ of two @Empty@s.
7) The first line of every layout in the left argument of @Union@ is
longer than the first line of any layout in the right argument.
(1) ensures that the left argument has a first line. In view of
(3), this invariant means that the right argument must have at
least two lines.
Notice the difference between
* NoDoc (no documents)
* Empty (one empty document; no height and no width)
* text "" (a document containing the empty string;
one line high, but has no width)
-}
-- | RDoc is a "reduced GDoc", guaranteed not to have a top-level Above or Beside.
type RDoc = Doc
-- | The TextDetails data type
--
-- A TextDetails represents a fragment of text that will be
-- output at some point.
data TextDetails = Chr {-# UNPACK #-} !Char -- ^ A single Char fragment
| Str String -- ^ A whole String fragment
| PStr FastString -- a hashed string
| ZStr FastZString -- a z-encoded string
| LStr {-# UNPACK #-} !PtrString
-- a '\0'-terminated array of bytes
| RStr {-# UNPACK #-} !Int {-# UNPACK #-} !Char
-- a repeated character (e.g., ' ')