Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 623
    • Merge requests 623
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Merge requests
  • !11109

Parser, renamer, type checker for @a-binders (#17594)

  • Review changes

  • Download
  • Patches
  • Plain diff
Open Andrei Borzenkov requested to merge wip/sand-witch/check-@-binders into master Aug 18, 2023
  • Overview 26
  • Commits 1
  • Pipelines 10
  • Changes 82

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

This MR introduces the 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 ExpPatTypes 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]
Edited Aug 23, 2023 by Simon Peyton Jones
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/sand-witch/check-@-binders