[Haskell-cafe] stack overflow when using ST monad
Gregory Wright
gwright at comcast.net
Thu Aug 24 18:51:29 EDT 2006
Hi Bulat!
On Aug 24, 2006, at 1:07 PM, Bulat Ziganshin wrote:
> 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
>
Alas, at the moment the last gives (in ghc-6.4.2),
Unexpected strictness annotation: !TagState
In the data type declaration for `Tag'
Failed, modules loaded: none.
Prelude>
> also, one can implement strict write operations:
>
> writeRef r x = writeSTRef r $! x
>
> or use my unboxed references (but not with Integer) -
> http://haskell.org/haskellwiki/Library/ArrayRef
>
I will look at this. Thanks!
Best Wishes,
Greg
>
> --
> Best regards,
> Bulat mailto:Bulat.Ziganshin at gmail.com
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list