[Haskell-beginners] Stack space overflow: using strict accumulator still fails

Hugo Ferreira hmf at inescporto.pt
Mon Oct 31 10:36:53 CET 2011


Hello,

Apologies for the late reply but I had to prep the code.

On 10/28/2011 09:43 AM, Daniel Fischer wrote:
> On Thursday 27 October 2011, 17:02:46, Hugo Ferreira wrote:
>> But something seems to be wrong here. If I do:
>>
>> scoreRule_ r zs = Z.foldlz' (scoreElem r) (0, 0) zs
>>     where scoreElem r s z =
>>             let (nCorrect, nIncorrect) = s in
>>             case ruleApplication r z of
>>               Just tag ->  if tag == correct
>>                           then (nCorrect+1, nIncorrect)
>>                           else  (nCorrect, nIncorrect+1)
>>               Nothing  ->  (nCorrect, nIncorrect)
>>             where c = Z.cursor z
>>                   (correct,_) = c
>>
>> it works correctly, however this does not work:
>>
>> scoreRule_ r zs = Z.foldlz' (scoreElem r) (0, 0) zs
>>     where scoreElem r (!nCorrect, !nIncorrect) z =
>>             case ruleApplication r z of
>>               Just tag ->  if tag == correct
>>                           then (nCorrect+1, nIncorrect)
>>                           else (nCorrect, nIncorrect+1)
>>               Nothing  ->  (nCorrect, nIncorrect)
>>             where c = Z.cursor z
>>                   (correct,_) = c
>>
>> I have been staring at this for some time now, but cannot
>> understand why it does not work. Any ideas?
>
> No. Looks perfectly okay (well, the indentation is wrong, but that's the
> same for the working version above and is probably due to the mail client).

Not really. That's pretty much the indentation I am using. I actually
had additional trace statements. Can you please tell me what's wrong?

> Can you post the complete source for diagnosis?
>

I have attached the code + cabal files. I think that is all that is
required. I am not sending the training data because it is too large
(+7 Mega bytes). That is available at http://nlpwp.org/nlpwp-data.zip

TIA,
Hugo F.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: postagger.cabal
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111031/dc575a5a/attachment-0001.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Setup.lhs
Type: text/x-literate-haskell
Size: 110 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111031/dc575a5a/attachment-0001.lhs>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.hs
Type: text/x-haskell
Size: 14242 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111031/dc575a5a/attachment-0001.hs>


More information about the Beginners mailing list