<?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: More Monads on the Cheap: Inlined fromMaybe</title>
	<atom:link href="http://osteele.com/archives/2008/02/inlined-frommaybe/feed" rel="self" type="application/rss+xml" />
	<link>http://osteele.com/archives/2008/02/inlined-frommaybe</link>
	<description>Languages of the real and artificial.</description>
	<lastBuildDate>Thu, 12 Feb 2009 00:20:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: vacation blogger</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-424</link>
		<dc:creator>vacation blogger</dc:creator>
		<pubDate>Thu, 17 Jul 2008 14:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-424</guid>
		<description>Thanks for this article, not sure I completely understand, but any help is appreciated.
</description>
		<content:encoded><![CDATA[<p>Thanks for this article, not sure I completely understand, but any help is appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: used electric golf carts </title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-423</link>
		<dc:creator>used electric golf carts </dc:creator>
		<pubDate>Sat, 05 Jul 2008 04:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-423</guid>
		<description>Sorry mate, but you simply lost me at the end. Can you give us a URL for an intro to understand the whole topic? like a newbie manual or something?</description>
		<content:encoded><![CDATA[<p>Sorry mate, but you simply lost me at the end. Can you give us a URL for an intro to understand the whole topic? like a newbie manual or something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baxter</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-422</link>
		<dc:creator>Baxter</dc:creator>
		<pubDate>Thu, 03 Jul 2008 09:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-422</guid>
		<description>What exactly is a code stylist?</description>
		<content:encoded><![CDATA[<p>What exactly is a code stylist?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hogar</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-421</link>
		<dc:creator>Hogar</dc:creator>
		<pubDate>Fri, 06 Jun 2008 18:16:25 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-421</guid>
		<description>Hi Oliver, thanks a lot for this in-depth article about this seldomly discussed topic.
It solved me quite a few problems i had with ruby.
Excellent work. 
Best regards
Hogar</description>
		<content:encoded><![CDATA[<p>Hi Oliver, thanks a lot for this in-depth article about this seldomly discussed topic.<br />
It solved me quite a few problems i had with ruby.<br />
Excellent work.<br />
Best regards<br />
Hogar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Westin</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-420</link>
		<dc:creator>Marcus Westin</dc:creator>
		<pubDate>Fri, 21 Mar 2008 11:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-420</guid>
		<description>Thank you for the thorough discussion on a subject so seemingly trivial yet so prevalent in the coder&#039;s day to day life.

May I offer a version of your compressed Ruby into what I consider a more idiomatic and cleaner Ruby?
&lt;code&gt;
# also accepts offer  nil, offer.products  nil
loaded = offer &amp;&amp; preloadAll(begin products = offer.products &#124;&#124; []; products.map &amp;:id));
&lt;/code&gt;

Ruby way:
&lt;code&gt;
# also accepts offer  nil, offer.products  nil - Rubyier version
loaded = preloadAll( (offer.products &#124;&#124; []).map { &#124;pr&#124; pr.id } ) if offer
&lt;/code&gt;

Reads much better I think.

Cheers!</description>
		<content:encoded><![CDATA[<p>Thank you for the thorough discussion on a subject so seemingly trivial yet so prevalent in the coder&#8217;s day to day life.</p>
<p>May I offer a version of your compressed Ruby into what I consider a more idiomatic and cleaner Ruby?<br />
<code><br />
# also accepts offer  nil, offer.products  nil<br />
loaded = offer &amp;&amp; preloadAll(begin products = offer.products || []; products.map &amp;:id));<br />
</code></p>
<p>Ruby way:<br />
<code><br />
# also accepts offer  nil, offer.products  nil - Rubyier version<br />
loaded = preloadAll( (offer.products || []).map { |pr| pr.id } ) if offer<br />
</code></p>
<p>Reads much better I think.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oliver</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-419</link>
		<dc:creator>oliver</dc:creator>
		<pubDate>Mon, 03 Mar 2008 16:05:08 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-419</guid>
		<description>I agree that thinking in types saves headaches.  The point of the post was to extend code that worked only if @products@ had type &lt;code&gt;Array!&lt;/code&gt; (a non-nullable Array, to borrow ECMAScript 4.0 notation), such that it could handle &lt;code&gt;Array?&lt;/code&gt; (analogous Haskell &lt;code&gt;Maybe []&lt;/code&gt;, or Scala &lt;code&gt;Option[List]&lt;/code&gt; -- arrays aren&#039;t the same as lists, but JavaScript arrays are used where Haskell and Scala use lists).  The new code is only valid if the type of @products@ is a nullable array.  It won&#039;t work if you throw arbitrary data at it.  After all, if products could be _anything_, it might be an object with a @length@ _method_, and then @count@ would end up with the wrong type too.</description>
		<content:encoded><![CDATA[<p>I agree that thinking in types saves headaches.  The point of the post was to extend code that worked only if <code>products</code> had type <code>Array!</code> (a non-nullable Array, to borrow ECMAScript 4.0 notation), such that it could handle <code>Array?</code> (analogous Haskell <code>Maybe []</code>, or Scala <code>Option[List]</code> &#8212; arrays aren&#8217;t the same as lists, but JavaScript arrays are used where Haskell and Scala use lists).  The new code is only valid if the type of <code>products</code> is a nullable array.  It won&#8217;t work if you throw arbitrary data at it.  After all, if products could be <em>anything</em>, it might be an object with a <code>length</code> <em>method</em>, and then <code>count</code> would end up with the wrong type too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-418</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 03 Mar 2008 14:47:11 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-418</guid>
		<description>Type checking will save you some headaches.  For example: 

&lt;code&gt;var count = (products &#124;&#124; []).length;&lt;/code&gt;

In the expression above, if products === Boolean true, an error will be thrown when trying to read the length property of a Boolean value.  I&#039;m all for short, sweet code, but better safe than sorry. </description>
		<content:encoded><![CDATA[<p>Type checking will save you some headaches.  For example: </p>
<p><code>var count = (products || []).length;</code></p>
<p>In the expression above, if products === Boolean true, an error will be thrown when trying to read the length property of a Boolean value.  I&#8217;m all for short, sweet code, but better safe than sorry. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Schuerig</title>
		<link>http://osteele.com/archives/2008/02/inlined-frommaybe/comment-page-1#comment-417</link>
		<dc:creator>Michael Schuerig</dc:creator>
		<pubDate>Thu, 28 Feb 2008 09:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://osteele.com/2008/02/26/more-monads-on-the-cheap-inlined-frommaybe#comment-417</guid>
		<description>In Ruby it would be advisable to use Array(products) instead of (products &#124;&#124; []). The former coerces its argument to an array, i.e., Array(nil) -&gt; [], Array(1) -&gt; [1], Array([1]) -&gt; [1].</description>
		<content:encoded><![CDATA[<p>In Ruby it would be advisable to use Array(products) instead of (products || []). The former coerces its argument to an array, i.e., Array(nil) -&gt; [], Array(1) -&gt; [1], Array(<a href="#fn1">1</a>) -&gt; [1].</p>
]]></content:encoded>
	</item>
</channel>
</rss>

