<div dir="ltr">On Sun, Mar 11, 2012 at 16:33, Henning Thielemann <span dir="ltr">&lt;<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>&gt;</span> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
On Sun, 11 Mar 2012, Brandon Allbery wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is looking up a missing key in a Map an exception?<br>
</blockquote>
<br></div>
It is certainly an exceptional situation. You want to know the value that is associated with a key, but the answer is not the wanted value, but no value at all.</blockquote><div><br></div><div>So you will insist that lookup when the key doesn&#39;t exist throw an exception? If not, why not?</div>
<div><br></div><div>If we&#39;re going to make interfacing with the system as difficult and minetrap-strewn as possible, then let&#39;s cut to the chase and switch to Agda.  Or we need to change a bunch of IO (Maybe x) to throw approved exceptions and make them suitably difficult to use for our walled garden instead of thinking about whether that&#39;s appropriate.</div>
<div><br></div><div>Or, just maybe, we just need to stop thinking of it&#39;s-in-IO-it-should-throw-an-exception-at-every-opportunity-instead-of-being-*usable*.  IO&#39;s enough of a sewer as it is without turning it into don&#39;t-think-about-it-just-hork-a-hairball too.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&quot;exception&quot; in what sense? Certainly not an exception in IO, since I do not like the implicitness of exceptions in IO. No I think, Maybe is a perfect return type for &#39;lookup&#39;. What I want to say is, that Nothing is also an exceptional value.<br>
</blockquote><div><br></div><div>(So, you just tossed in &lt;stdrant.h&gt; C-style without looking at the context?)</div><div><br></div><div>The context is that getEnv currently throws an IO exception if the name isn&#39;t found, and we&#39;d like it to be IO (Maybe String) because it&#39;s really a keyed store where absence of the key isn&#39;t really justification for an IO exception, but is a reasonable use for a Maybe.  It&#39;s the cranky IO exception that needs to go away, not the notion of an exceptional condition in general.</div>
<div><br></div></div>-- <br>brandon s allbery                                      <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available)     (412) 475-9364 vm/sms<br>
<br>
</div>