primops: Add comment describing type of atomicModifyMutVar#
ClosedPublic

Authored by bgamari on Mar 6 2017, 3:02 PM.

Details

Summary

This resolves Trac #13130. It's not entirely clear to me why we don't use an unboxed
tuple here but this is at least better than the status quo.

[skip ci]

Test Plan

Read it

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bgamari created this revision.Mar 6 2017, 3:02 PM

We can't use an unboxed tuple because it would require strict evaluation of the updater function (the reason atomicModifyMutVar# can be atomic is that it just builds a thunk).

dfeuer accepted this revision.Mar 6 2017, 4:15 PM
dfeuer added a subscriber: dfeuer.
This comment was removed by dfeuer.
This revision is now accepted and ready to land.Mar 6 2017, 4:15 PM

We can't use an unboxed tuple because it would require strict evaluation of the updater function (the reason atomicModifyMutVar# can be atomic is that it just builds a thunk).

Ahh, right. I forgot about the required laziness here.

dfeuer added a comment.Mar 6 2017, 4:34 PM

We could use a Church encoding or other CPSish thing here if we wanted,
instead of an actual pair. I don't know how that would affect performance.

This revision was automatically updated to reflect the committed changes.