[Haskell-cafe] stack overflow when using ST monad

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Aug 24 13:07:42 EDT 2006

Hello Brian,

Thursday, August 24, 2006, 4:16:41 PM, you wrote:

> I would make all the fields strict here, to be sure that no lazyness can
> creep about unseen eg:

>      data Tag s = Tag {
>          tagID :: !Int,
>          state :: !(STRef s TagState),
>          count :: !(STRef s Integer)
>    }

perhaps better:

      data Tag s = Tag {
          tagID :: !Int,
          state :: STRef s !TagState,
          count :: STRef s !Integer

although i don't even sure that this will compile (in this case we can
request it as wishful feature). in theory, this should allow to omit
'$!' from writeRef calls

also, one can implement strict write operations:

writeRef r x = writeSTRef r $! x

or use my unboxed references (but not with Integer) -

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list