Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,252
    • Issues 4,252
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 398
    • Merge Requests 398
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18768

Closed
Open
Opened Sep 29, 2020 by Krzysztof Gogolewski@monoidalDeveloper

Linear types: remember usage environment of a case

Every Core expression has a well-defined type (exprType). With linear types, it should likewise have a well-defined usage environment.

For case expressions, the usage environment is computed by checking all branches and taking sup. However, this trick doesn't work when there are no branches.

Current workaround: empty case has a special Bottom usage, which denotes an arbitrary usage (0, 1, Many).

Wart: this means that we have to overapproximate, e.g. in scaleUsage x Bottom we have to guess whether to return x or Zero and we cannot take infimum.

Desired solution:

(1) Just like a case expression remembers its type (Note [Why does Case have a 'Type' field?] in Core.hs), it should remember its usage environment. This data should be verified by Lint.

(2) Once this is done, we can remove the Bottom usage and the second field of UsageEnv. In this step, we have to infer the correct usage environment for empty case in the typechecker.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18768