Should we have primitive fill-once variables?
Carter Schonwald
carter.schonwald at gmail.com
Fri Jun 29 16:19:53 UTC 2018
i'm a little confused, whats the order of reads here?
Mvars have write wins, whats the order here? last writer runs first, first
writer runs last? (wouldn't there be starvation issues?)
On Fri, Jun 29, 2018 at 11:51 AM Joachim Breitner <mail at joachim-breitner.de>
wrote:
> Hi,
>
> when reading the subject I was expecting something like this:
>
> -- | Creates an empty IVar
> newIVar :: IO (IVar a)
>
> -- | pure! but blocks until the IVar is written
> readIVar :: IVar a -> a
>
> -- | tries to write to an IVar.
> -- Succeeds if it is empty (returning True)
> -- Does nothing if it has been written to (returning False)
> writeIVar :: IVar a -> a -> IO Bool
>
> Alternatively:
>
> -- | all in one
> newIVar :: IO (a, a -> IO Bool)
>
>
> Essentially a thunk, but with explicit control over filling it.
> In fact, people have implemented something like this using C-- hacks
> before: https://github.com/twanvl/unsafe-sequence
>
> > This would make MonadFix's implementation much nicer, I think :)
>
> This would suffice for MonadFix, right?
>
> Sorry for derailing the thread :-)
>
> Cheers,
> Joachim
>
> --
> Joachim Breitner
> mail at joachim-breitner.de
> http://www.joachim-breitner.de/
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20180629/5bc60e07/attachment.html>
More information about the ghc-devs
mailing list