[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
Sat Aug 19 14:06:54 UTC 2023



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


Commits:
816561b4 by Andrei Borzenkov at 2023-08-19T18:06:38+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]

- - - - -


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/Parser/Types.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/Expr.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/816561b451dee83619f7f6546b20dc4049f26201

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/816561b451dee83619f7f6546b20dc4049f26201
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/20230819/00521179/attachment.html>


More information about the ghc-commits mailing list