<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mark Needham &#187; Haskell</title>
	<atom:link href="http://www.markhneedham.com/blog/category/haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Mon, 13 Feb 2012 21:25:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Haskell: parse error on input `=&#8217;</title>
		<link>http://www.markhneedham.com/blog/2010/04/22/haskell-parse-error-on-input/</link>
		<comments>http://www.markhneedham.com/blog/2010/04/22/haskell-parse-error-on-input/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 23:35:27 +0000</pubDate>
		<dc:creator>Mark Needham</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=2379</guid>
		<description><![CDATA[I&#8217;ve been trying to follow the &#8216;Monads for Java/C++ programmers&#8216; post in ghci and getting the following type of error when trying out the code snippets: Prelude&#62; a = 3 &#160; &#60;interactive&#62;:1:2: parse error on input `=' I figured there must be something wrong with my installation of the compiler since I was copying and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to follow the &#8216;<a href="http://irekjozwiak.com/entry/2009/06/13/Monads-for-Java-C---programmers.html">Monads for Java/C++ programmers</a>&#8216; post in ghci and getting the following type of error when trying out the code snippets:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">Prelude<span style="color: #339933; font-weight: bold;">&gt;</span> a <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">3</span>
&nbsp;
<span style="color: #339933; font-weight: bold;">&lt;</span>interactive<span style="color: #339933; font-weight: bold;">&gt;</span>:<span style="color: red;">1</span>:<span style="color: red;">2</span>: parse <span style="font-weight: bold;">error</span> on input `<span style="color: #339933; font-weight: bold;">=</span>'</pre></div></div>

<p>I figured there must be something wrong with my installation of the compiler since I was copying and pasting the example across and having this problem. Having reinstalled that, however, I still had the same problem.</p>
<p>I eventually came across <a href="http://greenokapi.net/blog/2007/02/19/chapter-1-of-hudaks-haskell-school-of-expression/">this blog post</a> which points to a <a href="http://ircarchive.info/haskell/2007/2/19/27.html">mailing list thread from a few years ago</a> where pjd explains that the &#8216;let&#8217; construct is required when defining a variable from ghci and wouldn&#8217;t necessarily be needed in a normal program:</p>
<blockquote><p>
<strong>pjd</strong>	osfameron: about the ghci thing, you have to prefix definitions with &#8220;let&#8221;</p>
<p>as in: let simple x y z = x * (y + z)</p>
<p><strong>pjd</strong>	the reason for this is that ghci is in an implicit do block</p>
<p><strong>pjd</strong>	so it&#8217;s not exactly like top-level haskell
</p></blockquote>
<p>We have to use a &#8216;let&#8217; in front of any variable/function definitions and then it will work as expected:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">Prelude<span style="color: #339933; font-weight: bold;">&gt;</span> <span style="color: #06c; font-weight: bold;">let</span> a <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">3</span>
<span style="color: red;">3</span></pre></div></div>

<p><a href="http://book.realworldhaskell.org/read/getting-started.html">According to Real World Haskell</a>:</p>
<blockquote><p>
This syntax is ghci-specific<br />
The syntax for let that ghci accepts is not the same as we would use at the “top level” of a normal Haskell program.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.markhneedham.com/blog/2010/04/22/haskell-parse-error-on-input/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

