...
 
Commits (17)
# Configure git to ignore commits listed in this file with:
#
# git config blame.ignoreRevsFile .git-ignore-revs
# Module Hierarchy Renamings
af332442123878c1b61d236dce46418efcbe8750
255418da5d264fb2758bc70925adb2094f34adc3
1941ef4f050c0dfcb68229641fcbbde3a10f1072
528df8ecb4e2f9c78b1ae4ab7ff8230644e9b643
18a346a4b5a02b8c62e8eedb91b35c2d8e754b96
817f93eac4d13f680e8e3e7a25eb403b1864f82e
1b1067d14b656bbbfa7c47f156ec2700c9751549
240f5bf6f53515535be5bf3ef7632aa69ae21e3e
1500f0898e85316c7c97a2f759d83278a072ab0e
3ca52151881451ce5b3a7740d003e811b586140d
cf739945b8b28ff463dc44925348f20b3c1f22cb
da7f74797e8c322006eba385c9cbdce346dd1d43
6e2d9ee25bce06ae51d2f1cf8df4f7422106a383
d491a6795d507eabe35d8aec63c534d29f2d305b
99a9f51bf8207c79241fc0b685fadeb222a61292
eb6082358cdb5f271a8e4c74044a12f97352c52f
5119296440e6846c553c72b8a93afc5ecfa576f0
447864a94a1679b5b079e08bb7208a0005381cef
......@@ -349,6 +349,7 @@ basicKnownKeyNames
-- Strings and lists
unpackCStringName,
unpackCStringFoldrName, unpackCStringUtf8Name,
cstringLengthName,
-- Overloaded lists
isListClassName,
......@@ -428,10 +429,6 @@ basicKnownKeyNames
-- Annotation type checking
toAnnotationWrapperName
-- The Ordering type
, orderingTyConName
, ordLTDataConName, ordEQDataConName, ordGTDataConName
-- The SPEC type for SpecConstr
, specTyConName
......@@ -1014,10 +1011,11 @@ modIntName = varQual gHC_CLASSES (fsLit "modInt#") modIntIdKey
-- Base strings Strings
unpackCStringName, unpackCStringFoldrName,
unpackCStringUtf8Name, eqStringName :: Name
unpackCStringUtf8Name, eqStringName, cstringLengthName :: Name
unpackCStringName = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey
unpackCStringFoldrName = varQual gHC_CSTRING (fsLit "unpackFoldrCString#") unpackCStringFoldrIdKey
unpackCStringUtf8Name = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey
cstringLengthName = varQual gHC_CSTRING (fsLit "cstringLength#") cstringLengthIdKey
eqStringName = varQual gHC_BASE (fsLit "eqString") eqStringIdKey
-- The 'inline' function
......@@ -2097,7 +2095,7 @@ wildCardKey, absentErrorIdKey, augmentIdKey, appendIdKey,
unpackCStringUtf8IdKey, unpackCStringAppendIdKey,
unpackCStringFoldrIdKey, unpackCStringIdKey,
typeErrorIdKey, divIntIdKey, modIntIdKey,
absentSumFieldErrorIdKey :: Unique
absentSumFieldErrorIdKey, cstringLengthIdKey :: Unique
wildCardKey = mkPreludeMiscIdUnique 0 -- See Note [WildCard binders]
absentErrorIdKey = mkPreludeMiscIdUnique 1
......@@ -2124,6 +2122,7 @@ voidPrimIdKey = mkPreludeMiscIdUnique 21
typeErrorIdKey = mkPreludeMiscIdUnique 22
divIntIdKey = mkPreludeMiscIdUnique 23
modIntIdKey = mkPreludeMiscIdUnique 24
cstringLengthIdKey = mkPreludeMiscIdUnique 25
concatIdKey, filterIdKey, zipIdKey,
bindIOIdKey, returnIOIdKey, newStablePtrIdKey,
......
module GHC.Builtin.Names where
import GHC.Unit.Module
import GHC.Types.Unique
mAIN :: Module
liftedTypeKindTyConKey :: Unique
......@@ -202,8 +202,11 @@ names in GHC.Builtin.Names, so they use wTcQual, wDataQual, etc
-- that occurs in this list that name will be assigned the wired-in key we
-- define here.
--
-- Because of their infinite nature, this list excludes tuples, Any and implicit
-- parameter TyCons (see Note [Built-in syntax and the OrigNameCache]).
-- Because of their infinite nature, this list excludes
-- * tuples, including boxed, unboxed and constraint tuples
--- (mkTupleTyCon, unitTyCon, pairTyCon)
-- * unboxed sums (sumTyCon)
-- See Note [Infinite families of known-key names] in GHC.Builtin.Names
--
-- See also Note [Known-key names]
wiredInTyCons :: [TyCon]
......@@ -224,6 +227,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because they
, wordTyCon
, word8TyCon
, listTyCon
, orderingTyCon
, maybeTyCon
, heqTyCon
, eqTyCon
......
......@@ -62,7 +62,7 @@ import GHC.Utils.Asm
import GHC.CmmToAsm.Reg.Target
import GHC.Platform
import GHC.CmmToAsm.BlockLayout as BlockLayout
import Config
import GHC.Settings.Config
import GHC.CmmToAsm.Instr
import GHC.CmmToAsm.PIC
import GHC.Platform.Reg
......
......@@ -5,9 +5,9 @@ module GHC.CmmToAsm.Dwarf (
import GHC.Prelude
import GHC.Cmm.CLabel
import GHC.Cmm.Expr ( GlobalReg(..) )
import Config ( cProjectName, cProjectVersion )
import GHC.Core ( Tickish(..) )
import GHC.Cmm.Expr ( GlobalReg(..) )
import GHC.Settings.Config ( cProjectName, cProjectVersion )
import GHC.Core ( Tickish(..) )
import GHC.Cmm.DebugBlock
import GHC.Driver.Session
import GHC.Unit.Module
......
......@@ -63,8 +63,8 @@ import GHC.Data.FastString
import GHC.Utils.Misc
import GHC.Core.InstEnv ( instanceDFunId )
import GHC.Core.Coercion.Opt ( checkAxInstCo )
import GHC.Core.Arity ( typeArity )
import GHC.Types.Demand ( splitStrictSig, isDeadEndDiv )
import GHC.Core.Opt.Arity ( typeArity )
import GHC.Types.Demand ( splitStrictSig, isDeadEndDiv )
import GHC.Driver.Types
import GHC.Driver.Session
......@@ -1735,7 +1735,7 @@ argument to be made for allowing a situation like this:
Applying this rule can't turn a well-typed program into an ill-typed one, so
conceivably we could allow it. But we can always eta-expand such an
"undersaturated" rule (see 'GHC.Core.Arity.etaExpandToJoinPointRule'), and in fact
"undersaturated" rule (see 'GHC.Core.Opt.Arity.etaExpandToJoinPointRule'), and in fact
the simplifier would have to in order to deal with the RHS. So we take a
conservative view and don't allow undersaturated rules for join points. See
Note [Rules and join points] in OccurAnal for further discussion.
......
......@@ -11,7 +11,7 @@
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
-- | Arity and eta expansion
module GHC.Core.Arity
module GHC.Core.Opt.Arity
( manifestArity, joinRhsArity, exprArity, typeArity
, exprEtaExpandArity, findRhsArity, etaExpand
, etaExpandToJoinPoint, etaExpandToJoinPointRule
......@@ -1136,7 +1136,7 @@ mkEtaWW orig_n ppr_orig_expr in_scope orig_ty
-- TODO Check if we actually *are* changing any join points' types
subst_expr :: Subst -> CoreExpr -> CoreExpr
subst_expr = substExpr (text "GHC.Core.Arity:substExpr")
subst_expr = substExpr (text "GHC.Core.Opt.Arity:substExpr")
--------------
......
......@@ -16,7 +16,7 @@ import GHC.Driver.Session ( DynFlags )
import GHC.Types.Basic
import GHC.Core
import GHC.Types.Id
import GHC.Core.Arity ( typeArity )
import GHC.Core.Opt.Arity ( typeArity )
import GHC.Core.Utils ( exprIsCheap, exprIsTrivial )
import GHC.Data.Graph.UnVar
import GHC.Types.Demand
......@@ -384,7 +384,7 @@ the case for Core!
1. We need to ensure the invariant
callArity e <= typeArity (exprType e)
for the same reasons that exprArity needs this invariant (see Note
[exprArity invariant] in GHC.Core.Arity).
[exprArity invariant] in GHC.Core.Opt.Arity).
If we are not doing that, a too-high arity annotation will be stored with
the id, confusing the simplifier later on.
......
......@@ -66,6 +66,7 @@ import qualified Data.ByteString as BS
import Data.Int
import Data.Ratio
import Data.Word
import Data.Maybe (fromMaybe)
{-
Note [Constant folding]
......@@ -1257,6 +1258,8 @@ builtinRules
ru_nargs = 4, ru_try = match_append_lit },
BuiltinRule { ru_name = fsLit "EqString", ru_fn = eqStringName,
ru_nargs = 2, ru_try = match_eq_string },
BuiltinRule { ru_name = fsLit "CStringLength", ru_fn = cstringLengthName,
ru_nargs = 1, ru_try = match_cstring_length },
BuiltinRule { ru_name = fsLit "Inline", ru_fn = inlineIdName,
ru_nargs = 2, ru_try = \_ _ _ -> match_inline },
BuiltinRule { ru_name = fsLit "MagicDict", ru_fn = idName magicDictId,
......@@ -1477,6 +1480,30 @@ match_eq_string _ id_unf _
match_eq_string _ _ _ _ = Nothing
-----------------------------------------------------------------------
-- Illustration of this rule:
--
-- cstringLength# "foobar"# --> 6
-- cstringLength# "fizz\NULzz"# --> 4
--
-- Nota bene: Addr# literals are suffixed by a NUL byte when they are
-- compiled to read-only data sections. That's why cstringLength# is
-- well defined on Addr# literals that do not explicitly have an embedded
-- NUL byte.
--
-- See GHC issue #5218, MR 2165, and bytestring PR 191. This is particularly
-- helpful when using OverloadedStrings to create a ByteString since the
-- function computing the length of such ByteStrings can often be constant
-- folded.
match_cstring_length :: RuleFun
match_cstring_length env id_unf _ [lit1]
| Just (LitString str) <- exprIsLiteral_maybe id_unf lit1
-- If elemIndex returns Just, it has the index of the first embedded NUL
-- in the string. If no NUL bytes are present (the common case) then use
-- full length of the byte string.
= let len = fromMaybe (BS.length str) (BS.elemIndex 0 str)
in Just (Lit (mkLitInt (roPlatform env) (fromIntegral len)))
match_cstring_length _ _ _ _ = Nothing
---------------------------------------------------
-- The rule is this:
......
......@@ -880,9 +880,9 @@ we want plusInt's strictness to propagate to foo! But because it has
no manifest lambdas, it won't do so automatically, and indeed 'co' might
have type (Int->Int->Int) ~ T.
Fortunately, GHC.Core.Arity gives 'foo' arity 2, which is enough for LetDown to
Fortunately, GHC.Core.Opt.Arity gives 'foo' arity 2, which is enough for LetDown to
forward plusInt's demand signature, and all is well (see Note [Newtype arity] in
GHC.Core.Arity)! A small example is the test case NewtypeArity.
GHC.Core.Opt.Arity)! A small example is the test case NewtypeArity.
Historical Note [Product demands for function body]
......
......@@ -15,7 +15,7 @@ import GHC.Prelude
import GHC.Core
import GHC.Core.Utils
import GHC.Core.Make
import GHC.Core.Arity ( etaExpand )
import GHC.Core.Opt.Arity ( etaExpand )
import GHC.Core.Opt.Monad ( FloatOutSwitches(..) )
import GHC.Driver.Session
......
......@@ -24,7 +24,7 @@ import GHC.Core
import GHC.Core.FVs
import GHC.Core.Utils ( exprIsTrivial, isDefaultAlt, isExpandableApp,
stripTicksTopE, mkTicks )
import GHC.Core.Arity ( joinRhsArity )
import GHC.Core.Opt.Arity ( joinRhsArity )
import GHC.Types.Id
import GHC.Types.Id.Info
import GHC.Types.Basic
......
......@@ -74,7 +74,7 @@ import GHC.Core.Utils ( exprType, exprIsHNF
, isExprLevPoly
, collectMakeStaticArgs
)
import GHC.Core.Arity ( exprBotStrictness_maybe )
import GHC.Core.Opt.Arity ( exprBotStrictness_maybe )
import GHC.Core.FVs -- all of it
import GHC.Core.Subst
import GHC.Core.Make ( sortQuantVars )
......
......@@ -785,7 +785,7 @@ propagate the info that x's RHS is bottom to x's IdInfo as rapidly as
possible.
We use tryEtaExpandRhs on every binding, and it turns ou that the
arity computation it performs (via GHC.Core.Arity.findRhsArity) already
arity computation it performs (via GHC.Core.Opt.Arity.findRhsArity) already
does a simple bottoming-expression analysis. So all we need to do
is propagate that info to the binder's IdInfo.
......
......@@ -49,7 +49,7 @@ import GHC.Core.Ppr
import GHC.Core.TyCo.Ppr ( pprParendType )
import GHC.Core.FVs
import GHC.Core.Utils
import GHC.Core.Arity
import GHC.Core.Opt.Arity
import GHC.Core.Unfold
import GHC.Types.Name
import GHC.Types.Id
......@@ -830,6 +830,21 @@ Ticks into the LHS, which makes matching trickier. #10665, #10745.
Doing this to either side confounds tools like HERMIT, which seek to reason
about and apply the RULES as originally written. See #10829.
There is, however, one case where we are pretty much /forced/ to transform the
LHS of a rule: postInlineUnconditionally. For instance, in the case of
let f = g @Int in f
We very much want to inline f into the body of the let. However, to do so (and
be able to safely drop f's binding) we must inline into all occurrences of f,
including those in the LHS of rules.
This can cause somewhat surprising results; for instance, in #18162 we found
that a rule template contained ticks in its arguments, because
postInlineUnconditionally substituted in a trivial expression that contains
ticks. See Note [Tick annotations in RULE matching] in GHC.Core.Rules for
details.
Note [No eta expansion in stable unfoldings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we have a stable unfolding
......@@ -1251,6 +1266,10 @@ it's best to inline it anyway. We often get a=E; b=a from desugaring,
with both a and b marked NOINLINE. But that seems incompatible with
our new view that inlining is like a RULE, so I'm sticking to the 'active'
story for now.
NB: unconditional inlining of this sort can introduce ticks in places that
may seem surprising; for instance, the LHS of rules. See Note [Simplfying
rules] for details.
-}
postInlineUnconditionally
......@@ -1554,7 +1573,7 @@ Note [Eta-expanding at let bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We now eta expand at let-bindings, which is where the payoff comes.
The most significant thing is that we can do a simple arity analysis
(in GHC.Core.Arity.findRhsArity), which we can't do for free-floating lambdas
(in GHC.Core.Opt.Arity.findRhsArity), which we can't do for free-floating lambdas
One useful consequence of not eta-expanding lambdas is this example:
genMap :: C a => ...
......
......@@ -33,7 +33,7 @@ import GHC.Core.SimpleOpt ( collectBindersPushingCo )
import GHC.Core.Utils ( exprIsTrivial, getIdFromTrivialExpr_maybe
, mkCast, exprType )
import GHC.Core.FVs
import GHC.Core.Arity ( etaExpandToJoinPointRule )
import GHC.Core.Opt.Arity ( etaExpandToJoinPointRule )
import GHC.Types.Unique.Supply
import GHC.Types.Name
import GHC.Types.Id.Make ( voidArgId, voidPrimId )
......
......@@ -9,7 +9,7 @@ module GHC.Core.Opt.WorkWrap ( wwTopBinds ) where
import GHC.Prelude
import GHC.Core.Arity ( manifestArity )
import GHC.Core.Opt.Arity ( manifestArity )
import GHC.Core
import GHC.Core.Unfold ( certainlyWillInline, mkWwInlineRule, mkWorkerUnfolding )
import GHC.Core.Utils ( exprType, exprIsHNF )
......@@ -534,12 +534,12 @@ Note [Zapping DmdEnv after Demand Analyzer] above.
Note [Don't eta expand in w/w]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A binding where the manifestArity of the RHS is less than idArity of the binder
means GHC.Core.Arity didn't eta expand that binding. When this happens, it does so
for a reason (see Note [exprArity invariant] in GHC.Core.Arity) and we probably have
means GHC.Core.Opt.Arity didn't eta expand that binding. When this happens, it does so
for a reason (see Note [exprArity invariant] in GHC.Core.Opt.Arity) and we probably have
a PAP, cast or trivial expression as RHS.
Performing the worker/wrapper split will implicitly eta-expand the binding to
idArity, overriding GHC.Core.Arity's decision. Other than playing fast and loose with
idArity, overriding GHC.Core.Opt.Arity's decision. Other than playing fast and loose with
divergence, it's also broken for newtypes:
f = (\xy.blah) |> co
......
......@@ -714,11 +714,15 @@ match :: RuleMatchEnv
-> CoreExpr -- Target
-> Maybe RuleSubst
-- We look through certain ticks. See note [Tick annotations in RULE matching]
-- We look through certain ticks. See Note [Tick annotations in RULE matching]
match renv subst e1 (Tick t e2)
| tickishFloatable t
= match renv subst' e1 e2
where subst' = subst { rs_binds = rs_binds subst . mkTick t }
match renv subst (Tick t e1) e2
-- Ignore ticks in rule template.
| tickishFloatable t
= match renv subst e1 e2
match _ _ e@Tick{} _
= pprPanic "Tick in rule" (ppr e)
......@@ -1016,7 +1020,7 @@ Hence, (a) the guard (not (isLocallyBoundR v2))
Note [Tick annotations in RULE matching]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We used to unconditionally look through Notes in both template and
We used to unconditionally look through ticks in both template and
expression being matched. This is actually illegal for counting or
cost-centre-scoped ticks, because we have no place to put them without
changing entry counts and/or costs. So now we just fail the match in
......@@ -1025,6 +1029,11 @@ these cases.
On the other hand, where we are allowed to insert new cost into the
tick scope, we can float them upwards to the rule application site.
Moreover, we may encounter ticks in the template of a rule. There are a few
ways in which these may be introduced (e.g. #18162, #17619). Such ticks are
ignored by the matcher. See Note [Simplifying rules] in
GHC.Core.Opt.Simplify.Utils for details.
cf Note [Notes in call patterns] in GHC.Core.Opt.SpecConstr
Note [Matching lets]
......
......@@ -22,7 +22,7 @@ module GHC.Core.SimpleOpt (
import GHC.Prelude
import GHC.Core.Arity( etaExpandToJoinPoint )
import GHC.Core.Opt.Arity( etaExpandToJoinPoint )
import GHC.Core
import GHC.Core.Subst
......
......@@ -50,7 +50,7 @@ import GHC.Driver.Session
import GHC.Core
import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr )
import GHC.Core.SimpleOpt
import GHC.Core.Arity ( manifestArity )
import GHC.Core.Opt.Arity ( manifestArity )
import GHC.Core.Utils
import GHC.Types.Id
import GHC.Types.Demand ( StrictSig, isDeadEndSig )
......
......@@ -1033,7 +1033,7 @@ getIdFromTrivialExpr_maybe e
{-
exprIsDeadEnd is a very cheap and cheerful function; it may return
False for bottoming expressions, but it never costs much to ask. See
also GHC.Core.Arity.exprBotStrictness_maybe, but that's a bit more
also GHC.Core.Opt.Arity.exprBotStrictness_maybe, but that's a bit more
expensive.
-}
......
......@@ -20,7 +20,7 @@ import GHC.Prelude
import GHC.Core
import GHC.Core.Utils ( exprType, findDefault, isJoinBind
, exprIsTickedString_maybe )
import GHC.Core.Arity ( manifestArity )
import GHC.Core.Opt.Arity ( manifestArity )
import GHC.Stg.Syntax
import GHC.Core.Type
......
......@@ -26,7 +26,7 @@ import GHC.Driver.Types
import GHC.Builtin.Names
import GHC.Types.Id.Make ( realWorldPrimId )
import GHC.Core.Utils
import GHC.Core.Arity
import GHC.Core.Opt.Arity
import GHC.Core.FVs
import GHC.Core.Opt.Monad ( CoreToDo(..) )
import GHC.Core.Lint ( endPassIO )
......@@ -1136,7 +1136,7 @@ After ANFing we get
and now we do NOT want eta expansion to give
f = /\a -> \ y -> (let s = h 3 in g s) y
Instead GHC.Core.Arity.etaExpand gives
Instead GHC.Core.Opt.Arity.etaExpand gives
f = /\a -> \y -> let s = h 3 in g s y
-}
......
......@@ -128,8 +128,9 @@ import Foreign
import GHC.Conc.Sync (sharedCAF)
#endif
import GHC.Base ( unpackCString#, unpackNBytes# )
#if __GLASGOW_HASKELL__ < 811
import GHC.Base (unpackCString#,unpackNBytes#)
#endif
-- | Gives the UTF-8 encoded bytes corresponding to a 'FastString'
bytesFS :: FastString -> ByteString
......
......@@ -246,12 +246,12 @@ import GHC.Unit.Parser
import GHC.Unit.Module
import {-# SOURCE #-} GHC.Driver.Plugins
import {-# SOURCE #-} GHC.Driver.Hooks
import {-# SOURCE #-} GHC.Builtin.Names ( mAIN )
import GHC.Builtin.Names ( mAIN )
import {-# SOURCE #-} GHC.Unit.State (PackageState, emptyPackageState, PackageDatabase, mkIndefUnitId, updateIndefUnitId)
import GHC.Driver.Phases ( Phase(..), phaseInputExt )
import GHC.Driver.Flags
import GHC.Driver.Ways
import Config
import GHC.Settings.Config
import GHC.Utils.CliOption
import GHC.Driver.CmdLine hiding (WarnReason(..))
import qualified GHC.Driver.CmdLine as Cmd
......
......@@ -25,7 +25,7 @@ module GHC.Hs (
module GHC.Hs.ImpExp,
module GHC.Hs.Lit,
module GHC.Hs.Pat,
module GHC.Hs.Types,
module GHC.Hs.Type,
module GHC.Hs.Utils,
module GHC.Hs.Doc,
module GHC.Hs.Extension,
......@@ -44,7 +44,7 @@ import GHC.Hs.ImpExp
import GHC.Hs.Lit
import GHC.Hs.Extension
import GHC.Hs.Pat
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Types.Basic ( Fixity, WarningTxt )
import GHC.Hs.Utils
import GHC.Hs.Doc
......
......@@ -31,7 +31,7 @@ import {-# SOURCE #-} GHC.Hs.Expr ( pprExpr, LHsExpr,
import {-# SOURCE #-} GHC.Hs.Pat ( LPat )
import GHC.Hs.Extension
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Core
import GHC.Tc.Types.Evidence
import GHC.Core.Type
......
......@@ -101,7 +101,7 @@ import {-# SOURCE #-} GHC.Hs.Expr( HsExpr, HsSplice, pprExpr,
-- Because Expr imports Decls via HsBracket
import GHC.Hs.Binds
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Hs.Doc
import GHC.Core.TyCon
import GHC.Types.Basic
......
......@@ -33,7 +33,7 @@ import GHC.Hs.Decls
import GHC.Hs.Pat
import GHC.Hs.Lit
import GHC.Hs.Extension
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Hs.Binds
-- others:
......
......@@ -22,7 +22,7 @@ import GHC.Hs.Binds
import GHC.Hs.Decls
import GHC.Hs.Expr
import GHC.Hs.Lit
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Hs.Pat
import GHC.Hs.ImpExp
......@@ -369,7 +369,7 @@ deriving instance (Data body) => Data (HsRecFields GhcRn body)
deriving instance (Data body) => Data (HsRecFields GhcTc body)
-- ---------------------------------------------------------------------
-- Data derivations from GHC.Hs.Types ----------------------------------
-- Data derivations from GHC.Hs.Type ----------------------------------
-- deriving instance (DataIdLR p p) => Data (LHsQTyVars p)
deriving instance Data (LHsQTyVars GhcPs)
......
......@@ -53,7 +53,7 @@ data HsLit x
-- ^ Unboxed character
| HsString (XHsString x) {- SourceText -} FastString
-- ^ String
| HsStringPrim (XHsStringPrim x) {- SourceText -} ByteString
| HsStringPrim (XHsStringPrim x) {- SourceText -} !ByteString
-- ^ Packed bytes
| HsInt (XHsInt x) IntegralLit
-- ^ Genuinely an Int; arises from
......
......@@ -58,7 +58,7 @@ import {-# SOURCE #-} GHC.Hs.Expr (SyntaxExpr, LHsExpr, HsSplice, pprLExpr, pprS
import GHC.Hs.Binds
import GHC.Hs.Lit
import GHC.Hs.Extension
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Tc.Types.Evidence
import GHC.Types.Basic
-- others:
......
......@@ -3,7 +3,7 @@
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
GHC.Hs.Types: Abstract syntax: user-defined types
GHC.Hs.Type: Abstract syntax: user-defined types
-}
{-# LANGUAGE DeriveDataTypeable #-}
......@@ -17,7 +17,7 @@ GHC.Hs.Types: Abstract syntax: user-defined types
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
module GHC.Hs.Types (
module GHC.Hs.Type (
HsType(..), NewHsTypeX(..), LHsType, HsKind, LHsKind,
HsTyVarBndr(..), LHsTyVarBndr, ForallVisFlag(..),
LHsQTyVars(..),
......
......@@ -110,7 +110,7 @@ import GHC.Hs.Decls
import GHC.Hs.Binds
import GHC.Hs.Expr
import GHC.Hs.Pat
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Hs.Lit
import GHC.Hs.Extension
......@@ -745,7 +745,7 @@ typeToLHsType ty
argf_to_spec :: ArgFlag -> Specificity
argf_to_spec Required = SpecifiedSpec
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
argf_to_spec (Invisible s) = s
go_tv :: TyVarBinder -> LHsTyVarBndr Specificity GhcPs
......
......@@ -41,7 +41,7 @@ import GHC.Core.SimpleOpt ( simpleOptExpr )
import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr )
import GHC.Core.Make
import GHC.Core.Utils
import GHC.Core.Arity ( etaExpand )
import GHC.Core.Opt.Arity ( etaExpand )
import GHC.Core.Unfold
import GHC.Core.FVs
import GHC.Data.Graph.Directed
......
......@@ -14,7 +14,7 @@ import GHC.Hs.Binds
import GHC.Hs.Doc
import GHC.Hs.Decls
import GHC.Hs.Extension
import GHC.Hs.Types
import GHC.Hs.Type
import GHC.Hs.Utils
import GHC.Types.Name
import GHC.Types.Name.Set
......
......@@ -1282,7 +1282,7 @@ repTy ty@(HsForAllTy { hst_fvf = fvf, hst_bndrs = tvs, hst_body = body }) =
case fvf of
ForallInvis -> repForallT ty
ForallVis -> let tvs' = map ((<$>) (setHsTyVarBndrFlag ())) tvs
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
in addHsTyVarBinds tvs' $ \bndrs ->
do body1 <- repLTy body
repTForallVis bndrs body1
......
......@@ -17,8 +17,7 @@ module GHC.Iface.Ext.Binary
where
import GHC.Settings.Utils ( maybeRead )
import Config ( cProjectVersion )
import GHC.Settings.Config ( cProjectVersion )
import GHC.Prelude
import GHC.Utils.Binary
import GHC.Iface.Binary ( getDictFastString )
......
......@@ -14,7 +14,7 @@ module GHC.Iface.Ext.Types where
import GHC.Prelude
import Config
import GHC.Settings.Config
import GHC.Utils.Binary
import GHC.Data.FastString ( FastString )
import GHC.Iface.Type
......
......@@ -29,7 +29,7 @@ import GHC.Core.Lint
import GHC.Core.Rules
import GHC.Core.PatSyn
import GHC.Core.ConLike
import GHC.Core.Arity ( exprArity, exprBotStrictness_maybe )
import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe )
import GHC.Iface.Tidy.StaticPtrTable
import GHC.Types.Var.Env
import GHC.Types.Var.Set
......
......@@ -3467,7 +3467,7 @@ qconop :: { Located RdrName }
-- Type constructors
-- See Note [Unit tuples] in GHC.Hs.Types for the distinction
-- See Note [Unit tuples] in GHC.Hs.Type for the distinction
-- between gtycon and ntgtycon
gtycon :: { Located RdrName } -- A "general" qualified tycon, including unit tuples
: ntgtycon { $1 }
......
......@@ -974,7 +974,7 @@ checkTyClHdr is_cls ty
arity = length ts
tup_name | is_cls = cTupleTyConName arity
| otherwise = getName (tupleTyCon Boxed arity)
-- See Note [Unit tuples] in GHC.Hs.Types (TODO: is this still relevant?)
-- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?)
go l _ _ _ _
= addFatalError l (text "Malformed head of type or class declaration:"
<+> ppr ty)
......
This diff is collapsed.
......@@ -59,7 +59,7 @@ import GHC.Types.Basic ( pprRuleName, TypeOrKind(..) )
import GHC.Data.FastString
import GHC.Types.SrcLoc as SrcLoc
import GHC.Driver.Session
import GHC.Utils.Misc ( debugIsOn, filterOut, lengthExceeds, partitionWith )
import GHC.Utils.Misc ( debugIsOn, lengthExceeds, partitionWith )
import GHC.Driver.Types ( HscEnv, hsc_dflags )
import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses )
import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..)
......@@ -664,7 +664,9 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds
rnFamInstEqn :: HsDocContext
-> AssocTyFamInfo
-> [Located RdrName] -- Kind variables from the equation's RHS
-> [Located RdrName]
-- ^ Kind variables from the equation's RHS to be implicitly bound
-- if no explicit forall.
-> FamInstEqn GhcPs rhs
-> (HsDocContext -> rhs -> RnM (rhs', FreeVars))
-> RnM (FamInstEqn GhcRn rhs', FreeVars)
......@@ -683,20 +685,36 @@ rnFamInstEqn doc atfi rhs_kvars
-- Use the "...Dups" form because it's needed
-- below to report unused binder on the LHS
-- Implicitly bound variables, empty if we have an explicit 'forall'.
-- See Note [forall-or-nothing rule] in GHC.Rename.HsType.
; let imp_vars = nubL $ forAllOrNothing (isJust mb_bndrs) pat_kity_vars_with_dups
; imp_var_names <- mapM (newTyVarNameRn mb_cls) imp_vars
; let bndrs = fromMaybe [] mb_bndrs
bnd_vars = map hsLTyVarLocName bndrs
payload_kvars = filterOut (`elemRdr` (bnd_vars ++ imp_vars)) rhs_kvars
-- Make sure to filter out the kind variables that were explicitly
-- bound in the type patterns.
; payload_kvar_names <- mapM (newTyVarNameRn mb_cls) payload_kvars
-- all names not bound in an explicit forall
; let all_imp_var_names = imp_var_names ++ payload_kvar_names
-- all_imp_vars represent the implicitly bound type variables. This is
-- empty if we have an explicit `forall` (see
-- Note [forall-or-nothing rule] in GHC.Rename.HsType), which means
-- ignoring:
--
-- - pat_kity_vars_with_dups, the variables mentioned in the LHS of
-- the equation, and
-- - rhs_kvars, the kind variables mentioned in an outermost kind
-- signature on the RHS of the equation. (See
-- Note [Implicit quantification in type synonyms] in
-- GHC.Rename.HsType for why these are implicitly quantified in the
-- absence of an explicit forall).
--
-- For example:
--
-- @
-- type family F a b
-- type instance forall a b c. F [(a, b)] c = a -> b -> c
-- -- all_imp_vars = []
-- type instance F [(a, b)] c = a -> b -> c
-- -- all_imp_vars = [a, b, c]
-- @
; all_imp_vars <- forAllOrNothing (isJust mb_bndrs) $
-- No need to filter out explicit binders (the 'mb_bndrs = Just
-- explicit_bndrs' case) because there must be none if we're going
-- to implicitly bind anything, per the previous comment.
nubL $ pat_kity_vars_with_dups ++ rhs_kvars
; all_imp_var_names <- mapM (newTyVarNameRn mb_cls) all_imp_vars
-- All the free vars of the family patterns
-- with a sensible binding location
......@@ -2096,14 +2114,14 @@ rnConDecl decl@(ConDeclGADT { con_names = names
-- That order governs the order the implicitly-quantified type
-- variable, and hence the order needed for visible type application
-- See #14808.
free_tkvs = extractHsTvBndrs explicit_tkvs $
extractHsTysRdrTyVarsDups (theta ++ arg_tys ++ [res_ty])
; implicit_bndrs <- forAllOrNothing explicit_forall
$ extractHsTvBndrs explicit_tkvs
$ extractHsTysRdrTyVarsDups (theta ++ arg_tys ++ [res_ty])
ctxt = ConDeclCtx new_names
; let ctxt = ConDeclCtx new_names
mb_ctxt = Just (inHsDocContext ctxt)
; traceRn "rnConDecl" (ppr names $$ ppr free_tkvs $$ ppr explicit_forall )
; rnImplicitBndrs (forAllOrNothing explicit_forall free_tkvs) $ \ implicit_tkvs ->
; rnImplicitBndrs implicit_bndrs $ \ implicit_tkvs ->
bindLHsTyVarBndrs ctxt mb_ctxt Nothing explicit_tkvs $ \ explicit_tkvs ->
do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt
; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args
......
......@@ -3,7 +3,7 @@ module GHC.Settings.Constants where
import GHC.Prelude
import Config
import GHC.Settings.Config
hiVersion :: Integer
hiVersion = read (cProjectVersionInt ++ cProjectPatchLevel) :: Integer
......
......@@ -14,7 +14,7 @@ import GHC.Prelude
import GHC.Settings.Platform
import GHC.Settings.Utils
import Config
import GHC.Settings.Config
import GHC.Utils.CliOption
import GHC.Utils.Fingerprint
import GHC.Platform
......
......@@ -427,7 +427,7 @@ argument, which we do not want because users should be able to write
solution is to switch the PartialTypeSignatures flags here to let the
typechecker know that it's checking a '@_' and do not emit hole
constraints on it. See related Note [Wildcards in visible kind
application] and Note [The wildcard story for types] in GHC.Hs.Types
application] and Note [The wildcard story for types] in GHC.Hs.Type
Ugh!
......@@ -772,7 +772,7 @@ tc_hs_type mode rn_ty@(HsListTy _ elt_ty) exp_kind
; checkWiredInTyCon listTyCon
; checkExpectedKind rn_ty (mkListTy tau_ty) liftedTypeKind exp_kind }
-- See Note [Distinguishing tuple kinds] in GHC.Hs.Types
-- See Note [Distinguishing tuple kinds] in GHC.Hs.Type
-- See Note [Inferring tuple kinds]
tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind
-- (NB: not zonking before looking at exp_k, to avoid left-right bias)
......@@ -953,7 +953,7 @@ And whenever we see a '@', we automatically turn on PartialTypeSignatures and
turn off hole constraint warnings, and do not call emitAnonTypeHole
under these conditions.
See related Note [Wildcards in visible type application] here and
Note [The wildcard story for types] in GHC.Hs.Types
Note [The wildcard story for types] in GHC.Hs.Type
Note [Skolem escape and forall-types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -1842,7 +1842,7 @@ tcNamedWildCardBinders :: [Name]
-> TcM a
-- Bring into scope the /named/ wildcard binders. Remember that
-- plain wildcards _ are anonymous and dealt with by HsWildCardTy
-- Soe Note [The wildcard story for types] in GHC.Hs.Types
-- Soe Note [The wildcard story for types] in GHC.Hs.Type
tcNamedWildCardBinders wc_names thing_inside
= do { wcs <- mapM (const newWildTyVar) wc_names
; let wc_prs = wc_names `zip` wcs
......@@ -3390,7 +3390,7 @@ tcHsPatSigType :: UserTypeCtxt
-- Used for type-checking type signatures in
-- (a) patterns e.g f (x::Int) = e
-- (b) RULE forall bndrs e.g. forall (x::Int). f x = x
-- See Note [Pattern signature binders and scoping] in GHC.Hs.Types
-- See Note [Pattern signature binders and scoping] in GHC.Hs.Type
--
-- This may emit constraints
-- See Note [Recipe for checking a signature]
......
......@@ -2128,7 +2128,7 @@ reify_for_all argf ty = do
case argToForallVisFlag argf of
ForallVis -> do phi' <- reifyType phi
let tvs = map (() <$) tvbndrs'
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
pure $ TH.ForallVisT tvs phi'
ForallInvis -> do let (cxt, tau) = tcSplitPhiTy phi
cxt' <- reifyCxt cxt
......
......@@ -38,7 +38,7 @@ import GHC.Utils.Outputable
import GHC.Driver.Session( DynFlags )
import GHC.Types.Name.Set
import GHC.Types.Name.Reader
import GHC.Hs.Types( HsIPName(..) )
import GHC.Hs.Type( HsIPName(..) )
import GHC.Data.Pair
import GHC.Utils.Misc
......
......@@ -554,7 +554,7 @@ tcInstTypeBndrs inst_tyvars id =
where
argf_to_spec :: VarBndr TyCoVar ArgFlag -> VarBndr TyCoVar Specificity
argf_to_spec (Bndr tv Required) = Bndr tv SpecifiedSpec
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
argf_to_spec (Bndr tv (Invisible s)) = Bndr tv s
tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType)
......
......@@ -5,7 +5,7 @@ import GHC.Tc.Utils.TcType ( TcTauType )
import GHC.Tc.Types ( TcM )
import GHC.Tc.Types.Evidence ( TcCoercion )
import GHC.Hs.Expr ( HsExpr )
import GHC.Hs.Types ( HsType )
import GHC.Hs.Type ( HsType )
import GHC.Hs.Extension ( GhcRn )
-- This boot file exists only to tie the knot between
......
......@@ -6,6 +6,7 @@
This module converts Template Haskell syntax into Hs syntax
-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
......@@ -1232,8 +1233,7 @@ cvtLit (CharPrimL c) = do { force c; return $ HsCharPrim NoSourceText c }
cvtLit (StringL s) = do { let { s' = mkFastString s }
; force s'
; return $ HsString (quotedSourceText s) s' }
cvtLit (StringPrimL s) = do { let { s' = BS.pack s }
; force s'
cvtLit (StringPrimL s) = do { let { !s' = BS.pack s }
; return $ HsStringPrim NoSourceText s' }
cvtLit (BytesPrimL (Bytes fptr off sz)) = do
let bs = unsafePerformIO $ withForeignPtr fptr $ \ptr ->
......@@ -1482,7 +1482,7 @@ cvtTypeKind ty_str ty
ForallVisT tvs ty
| null tys'
-> do { let tvs_spec = map (TH.SpecifiedSpec <$) tvs
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
; tvs_spec' <- cvtTvs tvs_spec
; ty' <- cvtType ty
; loc <- getL
......
......@@ -152,7 +152,7 @@ instance Outputable LeftOrRight where
-- "real work". So:
-- fib 100 has arity 0
-- \x -> fib x has arity 1
-- See also Note [Definition of arity] in GHC.Core.Arity
-- See also Note [Definition of arity] in GHC.Core.Opt.Arity
type Arity = Int
-- | Representation Arity
......
......@@ -780,7 +780,7 @@ idOneShotInfo :: Id -> OneShotInfo
idOneShotInfo id = oneShotInfo (idInfo id)
-- | Like 'idOneShotInfo', but taking the Horrible State Hack in to account
-- See Note [The state-transformer hack] in GHC.Core.Arity
-- See Note [The state-transformer hack] in GHC.Core.Opt.Arity
idStateHackOneShotInfo :: Id -> OneShotInfo
idStateHackOneShotInfo id
| isStateHackType (idType id) = stateHackOneShot
......@@ -790,7 +790,7 @@ idStateHackOneShotInfo id
-- This one is the "business end", called externally.
-- It works on type variables as well as Ids, returning True
-- Its main purpose is to encapsulate the Horrible State Hack
-- See Note [The state-transformer hack] in GHC.Core.Arity
-- See Note [The state-transformer hack] in GHC.Core.Opt.Arity
isOneShotBndr :: Var -> Bool
isOneShotBndr var
| isTyVar var = True
......
......@@ -345,7 +345,7 @@ levityInfo = bitfieldGetLevityInfo . bitfield
oneShotInfo :: IdInfo -> OneShotInfo
oneShotInfo = bitfieldGetOneShotInfo . bitfield
-- | 'Id' arity, as computed by 'GHC.Core.Arity'. Specifies how many arguments
-- | 'Id' arity, as computed by 'GHC.Core.Opt.Arity'. Specifies how many arguments
-- this 'Id' has to be applied to before it doesn any meaningful work.
arityInfo :: IdInfo -> ArityInfo
arityInfo = bitfieldGetArityInfo . bitfield
......
......@@ -114,7 +114,7 @@ data Literal
-- See Note [Types of LitNumbers] below for the
-- Type field.
| LitString ByteString -- ^ A string-literal: stored and emitted
| LitString !ByteString -- ^ A string-literal: stored and emitted
-- UTF-8 encoded, we'll arrange to decode it
-- at runtime. Also emitted with a @\'\\0\'@
-- terminator. Create with 'mkLitString'
......
......@@ -405,7 +405,7 @@ data ArgFlag = Invisible Specificity
-- (<) on ArgFlag means "is less visible than"
-- | Whether an 'Invisible' argument may appear in source Haskell.
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
-- see Note [Specificity in HsForAllTy] in GHC.Hs.Type
data Specificity = InferredSpec
-- ^ the argument may not appear in source Haskell, it is
-- only inferred.
......
......@@ -27,7 +27,7 @@ module GHC.Utils.Panic.Plain
#include "HsVersions.h"
import Config
import GHC.Settings.Config
import GHC.Utils.Exception as Exception
import GHC.Stack
import GHC.Prelude
......
......@@ -297,7 +297,7 @@ Library
GHC.StgToCmm.Utils
GHC.StgToCmm.ExtCode
GHC.Runtime.Heap.Layout
GHC.Core.Arity
GHC.Core.Opt.Arity
GHC.Core.FVs
GHC.Core.Lint
GHC.Core.Subst
......@@ -342,7 +342,7 @@ Library
GHC.Hs.Extension
GHC.Hs.Instances
GHC.Hs.Pat
GHC.Hs.Types
GHC.Hs.Type
GHC.Hs.Utils
GHC.Hs.Dump
GHC.Iface.Binary
......@@ -360,7 +360,7 @@ Library
GHC.Types.Annotations
GHC.Driver.CmdLine
GHC.Driver.CodeOutput
Config
GHC.Settings.Config
GHC.Settings.Constants
GHC.Driver.MakeFile
GHC.Driver.Phases
......
......@@ -46,7 +46,7 @@ $(foreach n,1 2 3, \
)
$(foreach n,1 2 3, \
$(eval compiler/stage$n/package-data.mk : compiler/stage$n/build/Config.hs) \
$(eval compiler/stage$n/package-data.mk : compiler/stage$n/build/GHC/Settings/Config.hs) \
$(eval compiler/stage$n/build/PlatformConstants.o : $(includes_GHCCONSTANTS_HASKELL_TYPE)) \
$(eval compiler/stage$n/build/GHC/Driver/Session.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)) \
$(eval compiler/stage$n/build/GHC/Driver/Session.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)) \
......@@ -63,11 +63,11 @@ HOSTPLATFORM_3 = $(TARGETPLATFORM)
define compilerConfig
# $1 = compile stage (1-indexed)
compiler/stage$1/build/Config.hs : mk/config.mk mk/project.mk | $$$$(dir $$$$@)/.
compiler/stage$1/build/GHC/Settings/Config.hs : mk/config.mk mk/project.mk | $$$$(dir $$$$@)/.
$$(call removeFiles,$$@)
@echo 'Creating $$@ ... '
@echo '{-# LANGUAGE CPP #-}' >> $$@
@echo 'module Config' >> $$@
@echo 'module GHC.Settings.Config' >> $$@
@echo ' ( module GHC.Version' >> $$@
@echo ' , cBuildPlatformString' >> $$@
@echo ' , cHostPlatformString' >> $$@
......
......@@ -79,12 +79,15 @@ Language
* GHC now consistently does eager instantiation during type inference.
As a consequence, visible type application (VTA) now only works when
the head of the application is:
* A variable
* An expression with a type signature
For example `(let x = blah in id) @Bool True` no longer typechecks.
You should write `let x = blah in id @Bool True` instead.
This change prepares the way for Quick Look impredicativity.
For example ``(let x = blah in id) @Bool True`` no longer typechecks.
You should write ``let x = blah in id @Bool True`` instead.
This change prepares the way for `Quick Look impredicativity
<https://gitlab.haskell.org/ghc/ghc/issues/18126>`_.
* GHC now allows users to manually define the specificity of type variable
binders. By marking a variable with braces ``{tyvar}`` or ``{tyvar :: kind}``,
......@@ -110,60 +113,65 @@ Runtime system
Template Haskell
~~~~~~~~~~~~~~~~
- Implement the Overloaded Quotations proposal (#246). The type of all quotation
forms have now been generalised in terms of a minimal interface necessary for the
implementation rather than the overapproximation of the ``Q`` monad.
- Implement the `Overloaded Quotations proposal (#246) <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst>`_.
The type of all quotation forms have now been generalised in terms of a
minimal interface necessary (the ``Quote`` type class) for the
implementation rather than the overapproximation of the ``Q`` monad.
- Template Haskell quotes now handle fixity declarations in ``let`` and
``where`` bindings properly. Previously, such fixity declarations would
be dropped when quoted due to a Template Haskell bug.
- Template Haskell quotes now handle fixity declarations in ``let`` and
``where`` bindings properly. Previously, such fixity declarations would
be dropped when quoted due to a Template Haskell bug.
- The ``-XTemplateHaskellQuotes`` extension now allows nested splices as nested
splices do not lead directly to compile-time evaluation. (!2288)
- The ``-XTemplateHaskellQuotes`` extension now allows nested splices as nested
splices do not lead directly to compile-time evaluation. (Merge request
`!2288 <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2288>`_)
Arrow notation
~~~~~~~~~~~~~~
- When combined with :extension:`Arrows`, the :extension:`LambdaCase` extension
now additionally allows ``\case`` syntax to be used as a command in ``proc``
notation.
- When combined with :extension:`Arrows`, the :extension:`LambdaCase` extension
now additionally allows ``\case`` syntax to be used as a command in ``proc``
notation.
- When combined with :extension:`Arrows`, the effects of the
:extension:`BlockArguments` extension now also apply to applications of
arrow control operators in ``(|`` banana brackets ``|)``: ::
- When combined with :extension:`Arrows`, the effects of the
:extension:`BlockArguments` extension now also apply to applications of
arrow control operators in ``(|`` banana brackets ``|)``: ::
(| untilA (increment -< x + y) do
within 0.5 -< x
... |)
(| untilA (increment -< x + y) do
within 0.5 -< x
... |)
``ghc-prim`` library
~~~~~~~~~~~~~~~~~~~~
- Add a known-key ``cstringLength#`` to ``GHC.CString`` that is eligible
for constant folding by a built-in rule.
``ghc`` library
~~~~~~~~~~~~~~~
- The type of the ``getAnnotations`` function has changed to better reflect
the fact that it returns two different kinds of annotations, those on
names and those on modules: ::
- The type of the ``getAnnotations`` function has changed to better reflect
the fact that it returns two different kinds of annotations, those on
names and those on modules: ::
getAnnotations :: Typeable a
=> ([Word8] -> a) -> ModGuts
-> CoreM (ModuleEnv [a], NameEnv [a])
getAnnotations :: Typeable a
=> ([Word8] -> a) -> ModGuts
-> CoreM (ModuleEnv [a], NameEnv [a])
- The meaning of the ``hs_fixds`` field of ``HsGroup`` has changed slightly.
It now only contains fixity signatures defined for top-level declarations
and class methods defined *outside* of the class itself. Previously,
``hs_fixds`` would also contain fixity signatures for class methods defined
*inside* the class, such as the fixity signature for ``m`` in the following
example: ::
- The meaning of the ``hs_fixds`` field of ``HsGroup`` has changed slightly.
It now only contains fixity signatures defined for top-level declarations
and class methods defined *outside* of the class itself. Previously,
``hs_fixds`` would also contain fixity signatures for class methods defined
*inside* the class, such as the fixity signature for ``m`` in the following
example: ::
class C a where
infixl 4 `m`
m :: a -> a -> a
class C a where
infixl 4 `m`
m :: a -> a -> a
If you wish to attain the previous behavior of ``hs_fixds``, use the new
``hsGroupTopLevelFixitySigs`` function, which collects all top-level fixity
signatures, including those for class methods defined inside classes.
If you wish to attain the previous behavior of ``hs_fixds``, use the new
``hsGroupTopLevelFixitySigs`` function, which collects all top-level fixity
signatures, including those for class methods defined inside classes.
- The ``Exception`` module was boiled down acknowledging the existence of
the ``exceptions`` dependency. In particular, the ``ExceptionMonad``
......@@ -176,6 +184,15 @@ Arrow notation
``base`` library
~~~~~~~~~~~~~~~~
- ``ForeignPtrContents`` has a new nullary data constructor ``FinalPtr``.
``FinalPtr`` is intended for turning a primitive string literal into a
``ForeignPtr``. Unlike ``PlainForeignPtr``, ``FinalPtr`` does not have
a finalizer. Replacing ``PlainForeignPtr`` that has ``NoFinalizers`` with
``FinalPtr`` reduces allocations, reduces the size of compiled binaries,
and unlocks important Core-to-Core optimizations. ``FinalPtr`` will be used
in an upcoming ``bytestring`` release to improve the performance of
``ByteString`` literals created with ``OverloadedStrings``.
Build system
~~~~~~~~~~~~
......@@ -196,7 +213,7 @@ for further change information.
libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library
libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library
libraries/directory/directory.cabal: Dependency of ``ghc`` library
libraries/exceptions/exceptions.cabal: Dependency of ``haskeline`` library
libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library
libraries/filepath/filepath.cabal: Dependency of ``ghc`` library
compiler/ghc.cabal: The compiler itself
libraries/ghci/ghci.cabal: The REPL interface
......
......@@ -74,7 +74,7 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under
that declaration splices are not allowed anywhere except at top level
(outside any other declarations).
The ``Q`` monad is a monad defined in ``Language.Haskell.TH.Syntax`` which
The ``Q`` monad is a monad defined in :th-ref:`Language.Haskell.TH.Syntax.` which
supports several useful operations during code generation such as reporting
errors or looking up identifiers in the environment.
......@@ -92,9 +92,10 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under
- ``[p| ... |]``, where the "..." is a pattern; the quotation has
type ``Quote m => m Pat``.
The ``Quote`` type class is the minimal interface necessary to implement
the desugaring of quotations. The ``Q`` monad is an instance of ``Quote`` but
contains many more operations which are not needed for defining quotations.
The ``Quote`` type class (:th-ref:`Language.Haskell.TH.Syntax.Quote`) is
the minimal interface necessary to implement the desugaring of quotations.
The ``Q`` monad is an instance of ``Quote`` but contains many more
operations which are not needed for defining quotations.
See :ref:`pts-where` for using partial type signatures in quotations.
......@@ -402,7 +403,7 @@ Using Template Haskell
----------------------
- The data types and monadic constructor functions for Template Haskell
are in the library ``Language.Haskell.TH.Syntax``.
are in the library :th-ref:`Language.Haskell.TH.Syntax.`.
- You can only run a function at compile time if it is imported from
another module. That is, you can't define a function in a module, and
......@@ -645,7 +646,7 @@ Here are the salient features
(Only the first two are described in the paper.)
- A quoter is a value of type
``Language.Haskell.TH.Quote.QuasiQuoter``, which is defined thus: ::
:th-ref:`Language.Haskell.TH.Quote.QuasiQuoter`, which is defined thus: ::
data QuasiQuoter = QuasiQuoter { quoteExp :: String -> Q Exp,
quotePat :: String -> Q Pat,
......
......@@ -1136,10 +1136,11 @@ Haddock
single: haddock
.. ghc-flag:: -haddock
:shortdesc: Make the parser more strict about Haddock comments.
:shortdesc: With this flag GHC will parse Haddock comments and include them
in the interface file it produces.
:type: dynamic
:reverse: -no-haddock
:category: misc
:category: haddock
By default, GHC ignores Haddock comments (``-- | ...`` and ``-- ^ ...``)
and does not check that they're associated with a valid term, such as a
......
......@@ -73,7 +73,7 @@ import GHC.Runtime.Loader ( initializePlugins )
-- Other random utilities
import GHC.Types.Basic hiding ( isTopLevel )
import Config
import GHC.Settings.Config
import GHC.Data.Graph.Directed
import GHC.Utils.Encoding
import GHC.Data.FastString
......
......@@ -46,7 +46,7 @@ import GHC.Unit.Module ( ModuleName, mkModuleName )
import GHC.HandleEncoding
import GHC.Platform
import GHC.Platform.Host
import Config
import GHC.Settings.Config
import GHC.Settings.Constants
import GHC.Driver.Types
import GHC.Unit.State ( pprPackages, pprPackagesSimple )
......
@echo off
set CABAL=cabal
set CABFLAGS=--disable-documentation --disable-profiling --disable-library-profiling
if "%CABAL%"=="" (
set CABAL=cabal
)
if "%CABFLAGS%"=="" (
set CABFLAGS=--disable-documentation --disable-profiling --disable-library-profiling
)
rem It is currently more robust to pass Cabal an absolute path to the project file.
set PROJ="%CD%/hadrian/cabal.project"
......
set TERM=dumb
set CABFLAGS=-v0
%CD%\hadrian\build-cabal.bat tool:%1 -q --build-root=_hie-bios --flavour=ghc-in-ghci > %HIE_BIOS_OUTPUT%
......@@ -114,7 +114,7 @@ generatePackageCode context@(Context stage pkg _) = do
priority 2.0 $ do
when (pkg == compiler) $ do
root -/- "**" -/- dir -/- "Config.hs" %> go generateConfigHs
root -/- "**" -/- dir -/- "GHC/Settings/Config.hs" %> go generateConfigHs
root -/- "**" -/- dir -/- "*.hs-incl" %> genPrimopCode context
when (pkg == ghcPrim) $ do
root -/- "**" -/- dir -/- "GHC/Prim.hs" %> genPrimopCode context
......@@ -346,7 +346,7 @@ generateConfigHs = do
cBooterVersion <- getSetting GhcVersion
return $ unlines
[ "{-# LANGUAGE CPP #-}"
, "module Config"
, "module GHC.Settings.Config"
, " ( module GHC.Version"
, " , cBuildPlatformString"
, " , cHostPlatformString"
......
......@@ -68,7 +68,7 @@ allDeps = do
root <- buildRoot
let dir = buildDir (vanillaContext Stage0 compiler)
need [ root -/- dir -/- "Config.hs" ]
need [ root -/- dir -/- "GHC" -/- "Settings" -/- "Config.hs" ]
need [ root -/- dir -/- "GHC" -/- "Parser.hs" ]
need [ root -/- dir -/- "GHC" -/- "Parser" -/- "Lexer.hs" ]
need [ root -/- dir -/- "GHC" -/- "Cmm" -/- "Parser.hs" ]
......
# This is a IDE configuration file which tells IDEs such as `ghcide` how
# to set up a GHC API session for this project.
#
# To use it in windows systems replace the config with
# cradle: {bios: {program: "./hadrian/hie-bios.bat"}}
#
# The format is documented here - https://github.com/mpickering/hie-bios
cradle: {bios: {program: "./hadrian/hie-bios"}}
......@@ -54,6 +54,14 @@ module GHC.Exts
-- * Overloaded string literals
IsString(..),
-- * CString
unpackCString#,
unpackAppendCString#,
unpackFoldrCString#,
unpackCStringUtf8#,
unpackNBytes#,
cstringLength#,
-- * Debugging
breakpoint, breakpointCond,
......
This diff is collapsed.
{-# LANGUAGE MagicHash, NoImplicitPrelude, BangPatterns #-}
{-# LANGUAGE MagicHash, NoImplicitPrelude, BangPatterns, UnliftedFFITypes #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.CString
......@@ -18,7 +17,7 @@
module GHC.CString (
unpackCString#, unpackAppendCString#, unpackFoldrCString#,
unpackCStringUtf8#, unpackNBytes#
unpackCStringUtf8#, unpackNBytes#, cstringLength#
) where
import GHC.Types
......@@ -174,3 +173,17 @@ unpackNBytes# addr len# = unpack [] (len# -# 1#)
case indexCharOffAddr# addr i# of
ch -> unpack (C# ch : acc) (i# -# 1#)
-- The return type is not correct here. We really want CSize,
-- but that type is defined in base. However, CSize should always
-- match the size of a machine word (I hope), so this is probably
-- alright on all platforms that GHC supports.
foreign import ccall unsafe "strlen" c_strlen :: Addr# -> Int#
-- | Compute the length of a NUL-terminated string. This address
-- must refer to immutable memory. GHC includes a built-in rule for
-- constant folding when the argument is a statically-known literal.
-- That is, a core-to-core pass reduces the expression
-- @cstringLength# "hello"#@ to the constant @5#@.
cstringLength# :: Addr# -> Int#
{-# INLINE[0] cstringLength# #-}
cstringLength# = c_strlen