Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,869
    • Issues 4,869
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • 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 Compiler
  • GHCGHC
  • Issues
  • #18739
Closed
Open
Created Sep 23, 2020 by Arnaud Spiwack@aspiwackDeveloper

Infer multiplicity of let expression

Motivation

In a let expression let x = rhs in u, x is always bound with multiplicity Many (and, correspondingly, u is consumed with multiplicity Many).

This also holds of where expression u where x = rhs.

The situation is similar to that of case expression as in #18738 .

In #18461 , we are adding a syntax to force polymorphism, but programmers expect let expressions to know their multiplicity on their own (in particular, they expect let x = y in u to be the same as u[x\y], but if the latter consumes y linearly, the former never does in the current GHC).

Proposal

Infer the multiplicity of let binders instead of choosing Many systematically. The multiplicity would be a variable.

A small detail to pay attention to is that, in let pat = rhs in u, the outermost pattern of pat is lazy. Lazy pattern are only permissible in unrestricted patterns (one way to think about it is that the desugaring of lazy pattern is not linear).

The typechecker doesn't make this property very apparent, so we will have to be careful about it. I suppose the same issue arises in #18461 .

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking