<div dir="ltr"><div>Of course there is "return ()" missing.<br><br><span style="font-family:courier new,monospace">check x assoc = case lookup x of<br></span><span style="font-family:courier new,monospace"> Just found -> putStrLn ("found " ++ found)<br>
</span></div><span style="font-family:courier new,monospace">
_ -> return ()</span><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 5:34 PM, Krzysztof Skrzętnicki <span dir="ltr"><<a href="mailto:gtener@gmail.com" target="_blank">gtener@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"><div><div><div>I'd rather use pattern matching in this case:<br><br></div><span style="font-family:courier new,monospace">check x assoc = case lookup x of<br>
</span></div><span style="font-family:courier new,monospace"> Just found -> putStrLn ("found " ++ found)<br>
_ -> </span><br><br></div>Not really shorter but I think it's cleaner this way.<br><div><div><br><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Aug 1, 2013 at 5:00 PM, vold <span dir="ltr"><<a href="mailto:voldermort@hotmail.com" target="_blank">voldermort@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've defined a function similar to<br>
<br>
check x assoc = let found = lookup x assoc in<br>
when (isJust found) $ putStrLn $ "found " ++ fromJust found<br>
<br>
which I've used several times from within the IO monad. Is there a more<br>
compact way of doing this?<br>
<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>