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,862
    • Issues 4,862
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • 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
  • #17693
Closed
Open
Created Jan 15, 2020 by Simon Peyton Jones@simonpjDeveloper

Improve and document atomicModifyMutVar2#

The primop atomicModifyMutVar2# is ill-documented, and its type is extremely odd. Its declared type (in primops.txt.pp is

   MutVar# s a -> (a -> c) -> State# s -> (# State# s, a, c #)

but that's a lie. Its real type is more like this

   MutVar# s a -> (a -> (a,b)) -> State# s -> (# State# s, a, (a, b) #)

And there is other tricky and entirely un-documented stuff about it. It all comes from an accepted GHC Proposal 149: replace atomicModifyMutVar# primop, but much is unclear about it (to me anyway).

These topics are discussed in this email thread.

The thread ends up saying: I propose:

  • To give atomicModifyMutVar2# its proper type, with a pair, as in the proposal.
  • To do that, fiddle with genprimopcode, to allow it to parse tuples as well as unboxed tuples; not hard.
  • This would disallow all this stuff about “any type that has a first field looking like a”, restricting to pairs alone. This didn’t form part of the proposal, and was never documented.
  • Add a bit more clarity to the documentation, so it’d clear what must be forced.

This ticket is to record this task.

I've even done quite a bit of the work: see branch wip/T17693.

Edited Jan 15, 2020 by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking