[Haskell-beginners] Using IORef
Courtney Robinson
courtney at crlog.info
Tue Jan 7 03:31:58 UTC 2014
Cool. I think I get so i'll have a go.
Thanks again
On Tue, Jan 7, 2014 at 3:21 AM, Brandon Allbery <allbery.b at gmail.com> wrote:
> On Mon, Jan 6, 2014 at 10:15 PM, Courtney Robinson <courtney at crlog.info>wrote:
>>
>> On Tue, Jan 7, 2014 at 3:03 AM, Brandon Allbery <allbery.b at gmail.com>wrote:
>>
>>> behind
>>
>>
>> Oh I see, thanks for the info. really helpful.
>> It brings about another question now.
>>
>> How is newIORef meant to be used so that I only have a single IORef?
>>
>
> The Haskell way is to carry such things implicitly in a State or Reader
> monad; since the IORef itself doesn't change, and you need the IO monad
> around anyway to actually use it, you would use a ReaderT IORef IO and then
> use ask >>= liftIO . readIORef to get the value and similar to write or
> modify it. (Commonly one uses a type or newtype+newtype deriving to make
> one's own monad combining them.)
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
--
Courtney Robinson
courtney at crlog.info
http://crlog.info
07535691628 (No private #s)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140107/5ed65aee/attachment-0001.html>
More information about the Beginners
mailing list