<div dir="ltr"><div><div><div>I have also used this package as a quick-and-dirty-but-working solution to loading external resources at <span style class="">runtime</span> and performing caching if needed. This was something like this:<br>

<br></div><span style class="">loadConfigFile</span> :: IO <span style class="">SomeDataType</span><br></div><span style class="">loadConfigFile</span> = once (read <$> <span style class="">readFile</span> "foo.<span style class="">config</span>.<span style class="">txt</span>")<br>

<br></div>Except that <span style class="">config</span> file was actually ~50 MB long and parsed slowly.<br><div><div><div><div></div></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">There are obviously cases where caching such file is wrong or should be done in some structured fashion (like in <span style class="">Haxl</span>). Yet still, in other cases this is perfect tool to cut down development time.<br>

<br>--<br></div><div class="gmail_extra">Krzysztof<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 5:31 AM, Kim-<span style class="">Ee</span> <span style class="">Yeoh</span> <span dir="ltr"><<a href="mailto:ky3@atamo.com" target="_blank">ky3@<span style class="">atamo</span>.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">SimonM, SimonH, Dan: thank you all for the responses! Really helpful when deciding to use this package.<span class="HOEnZb"><font color="#888888"><br>

</font></span></div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div>-- Kim-Ee</div></font></span><div><div class="h5">
<br><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 2:16 AM, Dan Burton <span dir="ltr"><<a href="mailto:danburton.email@gmail.com" target="_blank">danburton.email@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



I created io-memoize a few years ago, around the same time that I also created <a href="http://hackage.haskell.org/package/runmemo" target="_blank">runmemo</a>. I was interested in "memoization" at the time, and was exploring various memoization techniques. It was just for theory/fun and had no motivating use case at the time.<div>




<br></div><div>I've been following various pipes/conduit discussions, and one particular discussion about WAI involved an interest in a "call once" callback. It's hard to enforce that sort of thing at the compile time without using hardcore solutions such as linear types or indexed monads, so the obvious solution is to use something like io-memoize to enforce it at runtime instead.</div>




<div><br></div><div><a href="http://www.reddit.com/r/haskell/comments/246e39/disemboweling_wai_aka_gutting_out_conduit/ch4cv55" target="_blank">http://www.reddit.com/r/haskell/comments/246e39/disemboweling_wai_aka_gutting_out_conduit/ch4cv55</a><br>




</div><div><br></div><div>Something else I've been working on lately is "the observer pattern" in Haskell. When you subscribe to an observer, it will give you a "subscription", which is just an action you can run to "unsubscribe" yourself. Again, there's potential for "once" to be useful here for implementing the unsubscribe action. If I manage to create something solid and novel out of this observer pattern stuff, then I'll release it to hackage as the "observable" package, or something like that.</div>




<div><br></div><div>Coincidentally, Simon pinged me about io-memoize with his use case in HSpec. So it's something that's been on my mind, but Simon came to me with a fresh Real Code use case that motivated the recent tweaks and the 1.1 release.<div>



<div><br>
<br><div>On Thu Jun 12 2014 at 3:28:47 AM, Simon Hengel <<a href="mailto:sol@typeful.net" target="_blank">sol@typeful.net</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




Hi Kim-Ee,<br>
<br>
> I may want a one-time only IO action, although so far the need hasn't<br>
> arisen yet. ;)<br>
><br>
> In the spirit of pilfering while the buns are still hot out of the oven, is<br>
> there a backstory for this package you could possibly sketch out? Some<br>
> canonical use case maybe?<br>
<br>
I use it to implement beforeAll/beforeAllWith[1] in Hspec[2].  I have<br>
been reluctant to add them because used in the wrong way they lead to<br>
bad/order dependent test cases.  But there are some valid use cases.  So<br>
I decided to finally add them.<br>
<br>
Cheers,<br>
Simon<br>
<br>
[1] <a href="https://github.com/hspec/hspec/pull/173" target="_blank">https://github.com/hspec/<u></u>hspec/pull/173</a><br>
[2] <a href="http://hspec.github.io/" target="_blank">http://hspec.github.io/</a><br>
</blockquote></div></div></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div></div>