ndmitchell / extra

Extra Haskell functions
Other
93 stars 37 forks source link

Consider adding strict Var primitives #79

Closed ndmitchell closed 3 years ago

ndmitchell commented 3 years ago

See the diff at https://github.com/haskell/haskell-language-server/pull/1553. Inspired, but not directly following that code, my inclination would be:

modifyVar' :: Var a -> (a -> IO (a, b)) -> IO b
modifyVar_' :: Var a -> (a -> IO a) -> IO ()
writeVar' :: Var a -> a -> IO ()

All of which update the Var, and then, without the lock held, evaluate the a they just put inside the Var. CC @pepeiborra - does that sound plausible? I think that Ghcide having a custom Control.Concurrent.Strict wrapper that only exposes the strict variants is still likely to be useful for that project, but it could be done on top of those three.

pepeiborra commented 3 years ago

Perfect

ndmitchell commented 3 years ago

Patch most welcome (otherwise I'll get to it, but today I'm focusing on Shake stuff!)