[Haskell] Re: ST/STRef vs. IO/IORef

Till Mossakowski till at informatik.uni-bremen.de
Fri Aug 5 05:31:40 EDT 2005


Bulat Ziganshin wrote:
> Hello Till,
> 
> Friday, August 05, 2005, 10:04:53 AM, you wrote:
> 
> TM>                MonadState  IOArray IOArray          ST
> TM>                with                with             with
> TM>                FiniteMap           unsafePerformIO  MutArr
> 
> TM> safe           yes        yes         no            yes
> 
> TM> efficient      no         yes         yes           yes
> 
> 
> afaik, ST efficient only with small enough arrays. one time i tried
> STArray of about 100 000 elements and seen that things goes much worse
> than in IO monad with IOArray. on small arrays STArray performs good
> enough
> 
> (i was trying to create sorting routine. afair, it was an insert sort)

That is weird, because in base/GHC/IOBase.lhs, IOArray is constructed
on top of STArray:

newtype IOArray i e = IOArray (STArray RealWorld i e)

But maybe ghc has some special treatment of IOArray.

Till
-- 
Till Mossakowski               Phone +49-421-218-4683
Dept. of Computer Science      Fax +49-421-218-3054
University of Bremen           till at tzi.de
P.O.Box 330440, D-28334 Bremen http://www.tzi.de/~till


More information about the Haskell mailing list