<?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: Foray Into Haskell</title>
	<atom:link href="http://www.akrish.net/2009/06/24/foray-into-haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/</link>
	<description>Thoughts, ideas and more</description>
	<lastBuildDate>Sun, 22 Jan 2012 00:22:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: akrish &#187; Blog Archive &#187; Dynamic Programming in Haskell and why DP is useful</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-220</link>
		<dc:creator>akrish &#187; Blog Archive &#187; Dynamic Programming in Haskell and why DP is useful</dc:creator>
		<pubDate>Sun, 28 Jun 2009 19:01:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-220</guid>
		<description>[...] and as I like to learn by doing, I&#8217;ve been implementing common algorithms in the language. Last week I tackled depth first search and found it to be surprisingly challenging and consequently really [...]</description>
		<content:encoded><![CDATA[<p>[...] and as I like to learn by doing, I&#8217;ve been implementing common algorithms in the language. Last week I tackled depth first search and found it to be surprisingly challenging and consequently really [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akshayk</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-215</link>
		<dc:creator>akshayk</dc:creator>
		<pubDate>Fri, 26 Jun 2009 18:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-215</guid>
		<description>@Jedai: yes you&#039;re right. I mentioned that I just started learning Haskell and in as much as I&#039;ve learned, I haven&#039;t gotten to Array&#039;s yet. I&#039;m sure they are very cool and highly useful as a language construct. 
Also thanks for the FGL link. I will check that out.</description>
		<content:encoded><![CDATA[<p>@Jedai: yes you&#8217;re right. I mentioned that I just started learning Haskell and in as much as I&#8217;ve learned, I haven&#8217;t gotten to Array&#8217;s yet. I&#8217;m sure they are very cool and highly useful as a language construct.<br />
Also thanks for the FGL link. I will check that out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jedaï</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-204</link>
		<dc:creator>Jedaï</dc:creator>
		<pubDate>Thu, 25 Jun 2009 18:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-204</guid>
		<description>Why do you consider immutable arrays &quot;cheating&quot; ? They&#039;re immutable, it&#039;s not like they&#039;re impure in any way. You can do lot of cool stuff with Haskell arrays : especially keeping in mind that they&#039;re lazy by default so you can use them in their own initialization, it&#039;s surprising how much can be done thanks to that.

I must say though that graphs and algorithms on them have always been something of a problem in pure functional languages, there are some interesting approach around (look at FGL http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fgl for instance).</description>
		<content:encoded><![CDATA[<p>Why do you consider immutable arrays &#8220;cheating&#8221; ? They&#8217;re immutable, it&#8217;s not like they&#8217;re impure in any way. You can do lot of cool stuff with Haskell arrays : especially keeping in mind that they&#8217;re lazy by default so you can use them in their own initialization, it&#8217;s surprising how much can be done thanks to that.</p>
<p>I must say though that graphs and algorithms on them have always been something of a problem in pure functional languages, there are some interesting approach around (look at FGL <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fgl" rel="nofollow">http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fgl</a> for instance).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akshayk</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-203</link>
		<dc:creator>akshayk</dc:creator>
		<pubDate>Thu, 25 Jun 2009 13:54:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-203</guid>
		<description>Thanks for the comments guys. Good to know people are interested... 
@InternetGuy: As I mentioned, I&#039;m still really knew to Haskell so thanks for the &quot;deriving&quot; tip. I should caught that unnecessary lambda though. Didn&#039;t know about list comprehensions so thanks for that too!
@jberryman these are all techniques i&#039;ve read about but didn&#039;t know it is the norm in terms of programming practices. Thanks!</description>
		<content:encoded><![CDATA[<p>Thanks for the comments guys. Good to know people are interested&#8230;<br />
@InternetGuy: As I mentioned, I&#8217;m still really knew to Haskell so thanks for the &#8220;deriving&#8221; tip. I should caught that unnecessary lambda though. Didn&#8217;t know about list comprehensions so thanks for that too!<br />
@jberryman these are all techniques i&#8217;ve read about but didn&#8217;t know it is the norm in terms of programming practices. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jberryman</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-200</link>
		<dc:creator>jberryman</dc:creator>
		<pubDate>Wed, 24 Jun 2009 22:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-200</guid>
		<description>... sorry about the formatting. I tried to stick it in a  tag</description>
		<content:encoded><![CDATA[<p>&#8230; sorry about the formatting. I tried to stick it in a  tag</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jberryman</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-199</link>
		<dc:creator>jberryman</dc:creator>
		<pubDate>Wed, 24 Jun 2009 22:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-199</guid>
		<description>Hi! Without really looking at what your code is doing or testing the following, I thought I would post a version of your last code block that is a little more idiomatic and better (and sometimes just different) in some other ways as well:


dfsIterateOverNeighbors :: Graph -&gt; [Integer] -&gt; [Node]
dfsIterateOverNeighbors g []      = []
dfsIterateOverNeighbors g (v:vs)  =
   let firstNode  = fromJust (getNode g v)
       newG       = removeNode g (getId firstNode)
       neighbors  = filter (isJust . getNode newG) (getAdjList firstNode)
       newToVisit = neighbors ++ filter (not . flip contains neighbors) vs 
   
   in  firstNode : dfsIterateOverNeighbors newG newToVisit


depthFirstSearch g =
    dfsIterateOverNeighbors g . return . getId . fromJust . getNode g 


Hope that type-checks!</description>
		<content:encoded><![CDATA[<p>Hi! Without really looking at what your code is doing or testing the following, I thought I would post a version of your last code block that is a little more idiomatic and better (and sometimes just different) in some other ways as well:</p>
<p>dfsIterateOverNeighbors :: Graph -&gt; [Integer] -&gt; [Node]<br />
dfsIterateOverNeighbors g []      = []<br />
dfsIterateOverNeighbors g (v:vs)  =<br />
   let firstNode  = fromJust (getNode g v)<br />
       newG       = removeNode g (getId firstNode)<br />
       neighbors  = filter (isJust . getNode newG) (getAdjList firstNode)<br />
       newToVisit = neighbors ++ filter (not . flip contains neighbors) vs </p>
<p>   in  firstNode : dfsIterateOverNeighbors newG newToVisit</p>
<p>depthFirstSearch g =<br />
    dfsIterateOverNeighbors g . return . getId . fromJust . getNode g </p>
<p>Hope that type-checks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Some Internet Guy</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-197</link>
		<dc:creator>Some Internet Guy</dc:creator>
		<pubDate>Wed, 24 Jun 2009 21:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-197</guid>
		<description>You could also write makeNode more concisely with &lt;a href=&quot;http://en.wikipedia.org/wiki/List_comprehension&quot; rel=&quot;nofollow&quot;&gt;list comprehensions&lt;/a&gt;, which are supposed to look like set-builder notation:

&lt;code&gt;
makeNode ind eList = Node ind ([ y &#124; (x,y) &lt;- eList, x==ind] ++ [ x &#124; (x,y) &lt;- eList, y==ind])
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>You could also write makeNode more concisely with <a href="http://en.wikipedia.org/wiki/List_comprehension" rel="nofollow">list comprehensions</a>, which are supposed to look like set-builder notation:</p>
<p><code><br />
makeNode ind eList = Node ind ([ y | (x,y) &lt;- eList, x==ind] ++ [ x | (x,y) &lt;- eList, y==ind])<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Some Internet Guy</title>
		<link>http://www.akrish.net/blog/2009/06/24/foray-into-haskell/comment-page-1/#comment-196</link>
		<dc:creator>Some Internet Guy</dc:creator>
		<pubDate>Wed, 24 Jun 2009 21:07:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrish.net/?p=177#comment-196</guid>
		<description>You can automatically derive the Show class for your type.

&lt;code&gt;
data Node = Node Integer [Integer]
   deriving Show
&lt;/code&gt;

You can also derive Eq (equality comparison) and Read (simple parsing), among others.

Also, &#039;(\x -&gt; fst)&#039; can be written more concisely as &#039;fst&#039;.</description>
		<content:encoded><![CDATA[<p>You can automatically derive the Show class for your type.</p>
<p><code><br />
data Node = Node Integer [Integer]<br />
   deriving Show<br />
</code></p>
<p>You can also derive Eq (equality comparison) and Read (simple parsing), among others.</p>
<p>Also, &#8216;(\x -&gt; fst)&#8217; can be written more concisely as &#8216;fst&#8217;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

