<div dir="ltr"><a href="https://www.schoolofhaskell.com/user/edwardk/snippets/once">https://www.schoolofhaskell.com/user/edwardk/snippets/once</a><br><div><br></div><div>Cool trick :)</div></div><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">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>