<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Scala exceptions vs. pattern matching</title>
	<atom:link href="http://tardigra.de/?feed=rss2&#038;p=33" rel="self" type="application/rss+xml" />
	<link>http://tardigra.de/?p=33</link>
	<description>Various Software Engineering Ramblings</description>
	<lastBuildDate>Thu, 26 Aug 2010 11:03:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: chris_lewis</title>
		<link>http://tardigra.de/?p=33&#038;cpage=1#comment-17</link>
		<dc:creator>chris_lewis</dc:creator>
		<pubDate>Fri, 09 Apr 2010 20:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.themcwongs.com/?p=33#comment-17</guid>
		<description>There&#039;s more to monadic error handling than just forcing the developer to state via verbosity that he is aware of a potential error. Note that scala.Option defines a few higher-order functions, namely foreach, filter, map, and flatMap: &lt;a href=&quot;http://www.scala-lang.org/docu/files/api/scala/Option.html&quot; rel=&quot;nofollow&quot;&gt;http://www.scala-lang.org/docu/files/api/scala/...&lt;/a&gt;&lt;br&gt;&lt;br&gt;These allow us to pass behavior to an Option instance that will only execute if it has a value (ie an instance of Some). For example, to get a collection of the status updates:&lt;br&gt;&lt;br&gt;val matches = new HttpXMLMatches()&lt;br&gt;val url = &quot;http://twitter.com/statuses/public_timeline.xml&quot;&lt;br&gt;matches.getXML(url).map { _ \ &quot;status&quot;  &quot;text&quot; map { _ text } }&lt;br&gt;&lt;br&gt;This results in a Some[Seq[String]] of the text nodes of the status updates. You could also use for comprehensions:&lt;br&gt;&lt;br&gt;for(xml &lt;- matches.getXML(url)) yield (xml \ &quot;status&quot;  &quot;text&quot; map { _ text })&lt;br&gt;&lt;br&gt;Or if you just want to do some side-effecting action, like printing the text:&lt;br&gt;&lt;br&gt;for(xml &lt;- matches.getXML(url)) { println(xml \ &quot;status&quot;  &quot;text&quot; text) }&lt;br&gt;&lt;br&gt;I&#039;m still trying to work out some guidelines as to when monadic handling is preferable to exceptions.</description>
		<content:encoded><![CDATA[<p>There&#39;s more to monadic error handling than just forcing the developer to state via verbosity that he is aware of a potential error. Note that scala.Option defines a few higher-order functions, namely foreach, filter, map, and flatMap: <a href="http://www.scala-lang.org/docu/files/api/scala/Option.html" rel="nofollow"></a><a href="http://www.scala-lang.org/docu/files/api/scala/.." rel="nofollow">http://www.scala-lang.org/docu/files/api/scala/..</a>.</p>
<p>These allow us to pass behavior to an Option instance that will only execute if it has a value (ie an instance of Some). For example, to get a collection of the status updates:</p>
<p>val matches = new HttpXMLMatches()<br />val url = &#8220;http://twitter.com/statuses/public_timeline.xml&#8221;<br />matches.getXML(url).map { _ \ &#8220;status&#8221;  &#8220;text&#8221; map { _ text } }</p>
<p>This results in a Some[Seq[String]] of the text nodes of the status updates. You could also use for comprehensions:</p>
<p>for(xml &lt;- matches.getXML(url)) yield (xml \ &#8220;status&#8221;  &#8220;text&#8221; map { _ text })</p>
<p>Or if you just want to do some side-effecting action, like printing the text:</p>
<p>for(xml &lt;- matches.getXML(url)) { println(xml \ &#8220;status&#8221;  &#8220;text&#8221; text) }</p>
<p>I&#39;m still trying to work out some guidelines as to when monadic handling is preferable to exceptions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
