<?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: Norvig&#8217;s spell checker and idiomatic Haskell</title>
	<atom:link href="http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/</link>
	<description>Bryan O&#039;Sullivan&#039;s blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 06:41:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Daniel</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46131</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 15 May 2007 19:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46131</guid>
		<description>&quot;... not implementing the approach that would be best suited to Haskell (dynamic programming).&quot;

Could you be convinced to do that?  Would *love* to see that explained as nicely as you have explained this implementation.

I really enjoyed your article.</description>
		<content:encoded><![CDATA[<p>&#8220;&#8230; not implementing the approach that would be best suited to Haskell (dynamic programming).&#8221;</p>
<p>Could you be convinced to do that?  Would *love* to see that explained as nicely as you have explained this implementation.</p>
<p>I really enjoyed your article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miles Gould</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46105</link>
		<dc:creator>Miles Gould</dc:creator>
		<pubDate>Tue, 15 May 2007 16:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46105</guid>
		<description>Ah, OK. Though I think it&#039;s only messy because you have to define updateWith() yourself (and because defaultdicts aren&#039;t available on the Python interpreter I have to hand). If you want to do this kind of thing with folds rather than loops, then write updateWith once, stick it in a module somewhere, and import it when you need it :-)</description>
		<content:encoded><![CDATA[<p>Ah, OK. Though I think it&#8217;s only messy because you have to define updateWith() yourself (and because defaultdicts aren&#8217;t available on the Python interpreter I have to hand). If you want to do this kind of thing with folds rather than loops, then write updateWith once, stick it in a module somewhere, and import it when you need it <img src='http://www.serpentine.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan O'Sullivan</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46097</link>
		<dc:creator>Bryan O'Sullivan</dc:creator>
		<pubDate>Tue, 15 May 2007 15:40:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46097</guid>
		<description>Miles, I know about reduce, but as I pointed out and you confirm, the code you end up writing to use it to update a dict is messy.</description>
		<content:encoded><![CDATA[<p>Miles, I know about reduce, but as I pointed out and you confirm, the code you end up writing to use it to update a dict is messy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miles Gould</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46094</link>
		<dc:creator>Miles Gould</dc:creator>
		<pubDate>Tue, 15 May 2007 15:22:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46094</guid>
		<description>&lt;i&gt;The Python code is a fold, too; thereâ€™s just not a clean way to write a fold that augments a dict in Python. So instead we have a loop that somewhat obfuscates the fact that weâ€™re folding.&lt;/i&gt;

Huh? The reduce() function has been part of Python for as long as I&#039;ve been aware of the language, and the following works fine for me:
def updateWith(f, default):
        def curried(dict,index):
                if index in dict:
                        dict[index] = f(dict[index])
                else: dict[index] = default
                return dict
        return curried

print reduce(updateWith(lambda x: x + 1, 1), [1,2,3,4,5,1,3,7,0], {} This prints &lt;code&gt;{0: 1, 1: 2, 2: 1, 3: 2, 4: 1, 5: 1, 7: 1}&lt;/code&gt; as expected.

It would probably be considered poor style, though, and I believe there&#039;s an ongoing argument in the Python community as to whether reduce() and map() should be removed from the language entirely: I guess they don&#039;t buy your argument that code using map and fold is clearer than the equivalent code using loops :-)

Other than that, great article!</description>
		<content:encoded><![CDATA[<p><i>The Python code is a fold, too; thereâ€™s just not a clean way to write a fold that augments a dict in Python. So instead we have a loop that somewhat obfuscates the fact that weâ€™re folding.</i></p>
<p>Huh? The reduce() function has been part of Python for as long as I&#8217;ve been aware of the language, and the following works fine for me:<br />
def updateWith(f, default):<br />
        def curried(dict,index):<br />
                if index in dict:<br />
                        dict[index] = f(dict[index])<br />
                else: dict[index] = default<br />
                return dict<br />
        return curried</p>
<p>print reduce(updateWith(lambda x: x + 1, 1), [1,2,3,4,5,1,3,7,0], {} This prints <code>{0: 1, 1: 2, 2: 1, 3: 2, 4: 1, 5: 1, 7: 1}</code> as expected.</p>
<p>It would probably be considered poor style, though, and I believe there&#8217;s an ongoing argument in the Python community as to whether reduce() and map() should be removed from the language entirely: I guess they don&#8217;t buy your argument that code using map and fold is clearer than the equivalent code using loops <img src='http://www.serpentine.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Other than that, great article!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Korneliussen</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46049</link>
		<dc:creator>Harald Korneliussen</dc:creator>
		<pubDate>Tue, 15 May 2007 07:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46049</guid>
		<description>It does that. With optimisation, it seems to me foldl never causes trouble. Why shouldn&#039;t the compiler be better at strictness analysis than me?</description>
		<content:encoded><![CDATA[<p>It does that. With optimisation, it seems to me foldl never causes trouble. Why shouldn&#8217;t the compiler be better at strictness analysis than me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan O'Sullivan</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46024</link>
		<dc:creator>Bryan O'Sullivan</dc:creator>
		<pubDate>Tue, 15 May 2007 04:03:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46024</guid>
		<description>I&#039;ve fixed the article. Oops! In my defence, I had substituted &lt;code&gt;foldl&lt;/code&gt; for &lt;code&gt;foldl&#039;&lt;/code&gt; and found no difference in performance or memory use, and was even looking at profiler output and seeing a nice slow heap growth instead of an explosion. I conclude that the compiler was being cleverer than I was.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve fixed the article. Oops! In my defence, I had substituted <code>foldl</code> for <code>foldl'</code> and found no difference in performance or memory use, and was even looking at profiler output and seeing a nice slow heap growth instead of an explosion. I conclude that the compiler was being cleverer than I was.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek Elkins</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46022</link>
		<dc:creator>Derek Elkins</dc:creator>
		<pubDate>Tue, 15 May 2007 03:42:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46022</guid>
		<description>petekaz is correct.  As illustrated on http://www.haskell.org/hawiki/StackOverflow foldl will accumulate thunks and lead to a stack overflow in just about all cases.  foldl is pretty much useless.  foldl&#039; should be what is used if you have a strict function and foldr otherwise.</description>
		<content:encoded><![CDATA[<p>petekaz is correct.  As illustrated on <a href="http://www.haskell.org/hawiki/StackOverflow" rel="nofollow">http://www.haskell.org/hawiki/StackOverflow</a> foldl will accumulate thunks and lead to a stack overflow in just about all cases.  foldl is pretty much useless.  foldl&#8217; should be what is used if you have a strict function and foldr otherwise.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: petekaz</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46019</link>
		<dc:creator>petekaz</dc:creator>
		<pubDate>Tue, 15 May 2007 03:36:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46019</guid>
		<description>For more discussion on the subject, see this thread on the cafe mailing list:

http://thread.gmane.org/gmane.comp.lang.haskell.cafe/21780</description>
		<content:encoded><![CDATA[<p>For more discussion on the subject, see this thread on the cafe mailing list:</p>
<p><a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/21780" rel="nofollow">http://thread.gmane.org/gmane.comp.lang.haskell.cafe/21780</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Lyons</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46013</link>
		<dc:creator>Daniel Lyons</dc:creator>
		<pubDate>Tue, 15 May 2007 02:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46013</guid>
		<description>Wow!

I worked on this problem a month or two ago when Norvig&#039;s spellchecker hit Reddit, but my Haskell implementation was ugly, inefficient and probably incorrect. Your elucidation clarifies all of the problems I ran into and results in beautiful, concise code. This is a service to the world and I thank you!</description>
		<content:encoded><![CDATA[<p>Wow!</p>
<p>I worked on this problem a month or two ago when Norvig&#8217;s spellchecker hit Reddit, but my Haskell implementation was ugly, inefficient and probably incorrect. Your elucidation clarifies all of the problems I ran into and results in beautiful, concise code. This is a service to the world and I thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pied</title>
		<link>http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/comment-page-1/#comment-46011</link>
		<dc:creator>Pied</dc:creator>
		<pubDate>Tue, 15 May 2007 02:23:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.serpentine.com/blog/2007/05/14/norvigs-spell-checker-and-idiomatic-haskell/#comment-46011</guid>
		<description>Wow !
I&#039;m not sure whether this was intended to be used as a tutorial, but it really is the best example of Haskell I have ever read !
I wish you had written it a year or two earlier...

I am to show your article to many people I know who have been frightened with the usual Haskell articles...

P!</description>
		<content:encoded><![CDATA[<p>Wow !<br />
I&#8217;m not sure whether this was intended to be used as a tutorial, but it really is the best example of Haskell I have ever read !<br />
I wish you had written it a year or two earlier&#8230;</p>
<p>I am to show your article to many people I know who have been frightened with the usual Haskell articles&#8230;</p>
<p>P!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

