[Git][ghc/ghc][wip/sand-witch/check- at -binders] Parser, renamer, type checker for @a-binders (17594)

Andrei Borzenkov (@sand-witch) gitlab at gitlab.haskell.org
Thu Feb 8 08:42:44 UTC 2024



Andrei Borzenkov pushed to branch wip/sand-witch/check- at -binders at Glasgow Haskell Compiler / GHC


Commits:
98b3d92e by Andrei Borzenkov at 2024-02-08T12:42:30+04:00
Parser, renamer, type checker for @a-binders (17594)

As a part of GHC Proposal 448 were introduced invisible
type patterns (@a-patterns) in functions and lambdas:

  id1 :: a -> a
  id1 @t x = x :: t

  id2 :: a -> a
  id2 = \ @t x -> x :: t

Was introduced new data type ArgPat and now Match stores it
instead of Pat. ArgPat has two constructors: VisPat for
common patterns and InvisPat for @-patterns.

Parsing is implemented in production argpat. Was introduced
ArgPatBuilder to help post process new patterns.

Renaming of ArgPat is implemented in rnArgPats function.

Type checking is a bit tricky due to eager scolemisation.
It's implemented in new functions tcTopSkolemiseExpPatTys,
tcSkolemiseScopedExpPatTys, and tcArgPats. For more information
about hack with collecting `ExpPatType`s see Note
[Type-checking invisible type patterns: check mode]

Type-checking is currently limited by check mode and -XNoDeepSubsumption.

Examples of new code:

  id1 :: forall a. a -> a
  id1 @t x = x :: t

  id2 :: a -> a
  id2 @t x = x :: t

  id3 :: a -> a
  id3 = \ @t x -> x

  id_RankN :: (forall a. a -> a) -> a -> a
  id_RankN @t f = f @t

  id4 = id_RankN \ @t x -> x :: t

  id_list :: [forall a. a -> a]
  id_list = [\ @t x -> x]

Metric Increase:
  LargeRecord
  RecordUpdPerf

- - - - -


30 changed files:

- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Arrows.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Deriv/Functor.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Arrow.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Module.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98b3d92e5b58c735af510825e9d39f11cc8bea44

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98b3d92e5b58c735af510825e9d39f11cc8bea44
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240208/e0fb5652/attachment.html>


More information about the ghc-commits mailing list