David Roundy <[EMAIL PROTECTED]> wrote:

> {-# NOINLINE _progressData #-}
> _progressData :: IORef (Map String ProgressData)
> _progressData = unsafePerformIO $ newIORef empty
> 
> updateProgressData :: String 
>       -> (ProgressData -> ProgressData) 
>       -> IO ()
> updateProgressData k f = when (progressMode) $ modifyIORef
>                                       _progressData (adjust f k)
> 
The question I'm asking myself is why you would want to modify a
reference to an always empty Map, which would be the case if
unsafePerformIO performs its action every time. If it doesnt' (and
experience suggest that it doesn't, as does the faithful usage of
{-# NOINLINE #-}, BUT YOU'LL NEVER, EVER, KNOW), I'm wondering why you
don't create the IORef in beginTedious and pass it around. Possibly
even with an implicit parameter.

And, yes, without multiple writing threads locking is unnecessary, and
mostly even with multiple writing threads, if they don't read, too.


/me mandates the renaming of unsafePerformIO to
iReallyReallyThoughtReallyHardAboutThisAndThereReallyIsNoDifferentWayThanToUseThisDreadedUnsafePerformIO.

OTOH, I have no idea what causes the segfault. 

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to