<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>See <a href="http://comments.gmane.org/gmane.comp.lang.haskell.libraries/18980">http://comments.gmane.org/gmane.comp.lang.haskell.libraries/18980</a></div><div><br></div><div>The W part of RWS is bad for performance. Best approach is to implement R, W, and S using a strict StateT. </div><div><br></div><div>Will</div><div><br>On Jul 14, 2016, at 11:43, Lian Hung Hon <<a href="mailto:hon.lianhung@gmail.com">hon.lianhung@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div>I faced the same problem in an RWS monad, where adding a print to the evalRWS resolves the space leak. Obviously, it's not very elegant to clutter the output. I tried the unsafeInterleaveIO (works sometimes), seq/deepseq (works on Windows but not on Linux??), strictness annotations (didn't seem to help at all?), but finally settled on using pipes/conduit. It's remarkable how a streaming library is more practical than the language's core feature - laziness.<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2016 at 16:32, Matthew Bray <span dir="ltr"><<a href="mailto:mattjbray@gmail.com" target="_blank">mattjbray@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a href="https://www.schoolofhaskell.com/user/edwardk/snippets/once" target="_blank">https://www.schoolofhaskell.com/user/edwardk/snippets/once</a><br><div><br></div><div>Cool trick :)</div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Thu, 14 Jul 2016 at 08:56 Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, this is a very neat trick and very effective. (I couldn't acutally<br>
find it on Hoogle. Does anyone have a link?)<br>
<br>
On Thu, Jul 14, 2016 at 07:45:33AM +0000, Robin Palotai wrote:<br>
> For deepseq also see the"Once trick". I'm surprised it's not quoted more<br>
> often. In fact our would make sense to mention it in the deepseq docs.<br>
><br>
> On Wed, Jul 13, 2016, 21:32 David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br>
><br>
> > You have to be careful with deepseq. Using it in the wrong place can<br>
> > lead to very bad performance. It's a big hammer. Its blow can<br>
> > sometimes be softened using the NF type from the nf package, but it's<br>
> > really not the right thing most of the time.<br>
> ><br>
> > On Tue, Jul 12, 2016 at 11:56 PM, William Yager <<a href="mailto:will.yager@gmail.com" target="_blank">will.yager@gmail.com</a>><br>
> > wrote:<br>
> > > You probably want Control.DeepSeq. No extraneous work doing addition that<br>
> > > way either.<br>
> > ><br>
> > > Will<br>
> > ><br>
> > > On Tue, Jul 12, 2016 at 11:28 PM, Christopher Howard <<a href="mailto:ch.howard@zoho.com" target="_blank">ch.howard@zoho.com</a><br>
> > ><br>
> > > wrote:<br>
> > >><br>
> > >> After pondering this problem some more, I found a solution to the<br>
> > >> problem was to introduce strictness, not deep down in the StateReader<br>
> > >> monad, but rather at the top level, i.e., forcing evaluation of each<br>
> > >> Matrix as soon as it is pulled of the list of Matrices. I found I could<br>
> > >> do this simply by summing all the elements in each matrix and printing<br>
> > >> the sum to std out. With this approach, i successfully run the full<br>
> > >> program and never even saw my memory performance graph move up.<br>
> > >><br>
> > >> I suppose there might be a way to do the same thing more efficiently<br>
> > >> with seq...?<br>
> > >><br>
> > >> On 07/12/2016 06:39 PM, Christopher Howard wrote:<br>
> > >> > I guess I was hesitating on posting the entire program source code in<br>
> > an<br>
> > >> > cafe email. I suppose I could send you a tarball, if you really wanted<br>
> > >> > it...<br>
> > >> ><br>
> > >> > Matrix is from Data.Matrix<br>
> > >> ><br>
> > >> > <<br>
> > <a href="http://hackage.haskell.org/package/matrix-0.3.5.0/docs/Data-Matrix.html" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/matrix-0.3.5.0/docs/Data-Matrix.html</a>>.<br>
> > >> ><br>
> > >> > It is hard to understand how thunks alone would explain it... there<br>
> > >> > would be at most 2000 thunks, right? Unless... Could there be a thunk<br>
> > >> > for every single call to getElem? That would be a lot of thunks!<br>
> > >> ><br>
> > >> > Somebody suggested adding some strictness here... could you elaborate<br>
> > on<br>
> > >> > that? I tried inserting seq, but I didn't really understand how I was<br>
> > >> > supposed to use it...<br>
> > >> ><br>
> > >><br>
> > >> --<br>
> > >> <a href="http://qlfiles.net" rel="noreferrer" target="_blank">http://qlfiles.net</a><br>
> > >> To protect my privacy, please use PGP encryption. It's free and easy<br>
> > >> to use! My public key ID is 0x340EA95A (<a href="http://pgp.mit.edu" rel="noreferrer" target="_blank">pgp.mit.edu</a>).<br>
> > >><br>
> > >> _______________________________________________<br>
> > >> Haskell-Cafe mailing list<br>
> > >> To (un)subscribe, modify options or view archives go to:<br>
> > >> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > >> Only members subscribed via the mailman list are allowed to post.<br>
> > ><br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > Haskell-Cafe mailing list<br>
> > > To (un)subscribe, modify options or view archives go to:<br>
> > > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > > Only members subscribed via the mailman list are allowed to post.<br>
> > _______________________________________________<br>
> > Haskell-Cafe mailing list<br>
> > To (un)subscribe, modify options or view archives go to:<br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > Only members subscribed via the mailman list are allowed to post.<br>
<br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
</div></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Haskell-Cafe mailing list</span><br><span>To (un)subscribe, modify options or view archives go to:</span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a></span><br><span>Only members subscribed via the mailman list are allowed to post.</span></div></blockquote></body></html>