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
  • #7285
Closed
Open
Created Oct 01, 2012 by edsko@edsko.net@trac-edsko

mkWeakMVar is non-compositional

In base 4.6 addMVarFinalizer is deprecated in favour of mkWeakMVar of type

    mkWeakMVar :: MVar a -> IO () -> IO (Weak (MVar a))

This type makes it inherently non-compositional. For instance, if we have a larger datatype T that contains an MVar somewhere inside then there in no way to define mkWeakT in terms of mkWeakMVar; instead, mkWeakT would have to be defined along the lines of

    mkWeakT :: T a -> IO () -> IO (Weak (T a))
    mkWeakT m@(MkT (MVar m#) _) f = IO $ \s ->
      case mkWeak# m# m f s of (# s1, w #) -> (# s1, Weak w #)

It would be better if the type of mkWeakMVar would change to

    mkWeakMVar :: MVar a -> v -> Maybe (IO ()) -> IO (Weak v)

(i.e., following mkWeak rather than mkWeakPtr).

(The same comment goes for related functions such as mkWeakIORef.)

Trac metadata
Trac field Value
Version 7.6.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking