<?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>unsafePerformHack &#187; Haskell</title>
	<atom:link href="http://olsner.se/category/haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://olsner.se</link>
	<description>Perversions in Computer Science</description>
	<lastBuildDate>Tue, 03 May 2011 23:32:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Literate Haskell Blogging</title>
		<link>http://olsner.se/2008/02/05/literate-haskell-blogging/</link>
		<comments>http://olsner.se/2008/02/05/literate-haskell-blogging/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 00:11:13 +0000</pubDate>
		<dc:creator>olsner</dc:creator>
				<category><![CDATA[Blogs about blogging]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[literate haskell]]></category>
		<category><![CDATA[markdown]]></category>

		<guid isPermaLink="false">http://olsner.se/?p=9</guid>
		<description><![CDATA[An unfortunate thing with this markdown framework I&#8217;ve been using is that it requires me to indent code blocks by four spaces (or a tab). Editing such text in a web browser really sucks, so I&#8217;ve been thinking about how to hack in literate haskell support into markdown. Well, turns out, it wasn&#8217;t that hard [...]]]></description>
			<content:encoded><![CDATA[<p>An unfortunate thing with this markdown framework I&#8217;ve been using is that it requires me to indent code blocks by four spaces (or a tab). Editing such text in a web browser really sucks, so I&#8217;ve been thinking about how to hack in literate haskell support into markdown. Well, turns out, it wasn&#8217;t that hard after all.</p>

<p>After some real simple modification to the <a href="http://www.dougalstanton.net/blog/index.php/2007/12/15/syntax-highlighting-with-markdown-in-wordpress">markdown+geshi patch</a> referenced in my <a href="http://olsner.se/?p=3">previous blog post</a> I now have literate haskell support! The modification literally took less time than writing this post <img src='http://olsner.se/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Find my new patch attached at the bottom of the page.</p>

<p>So &#8211; the testing! (This should render as normal text.)</p>

<p><div>
<pre class="haskell" style="font-family:monospace;"><span style="color: #339933; font-weight: bold;">&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:and"><span style="font-weight: bold;">and</span></a> <span style="background-color: #3cb371;">&quot;this&quot;</span> <span style="color: #5d478b; font-style: italic;">{-should-}</span> <span style="color: #5d478b; font-style: italic;">-- be rendered as haskell</span></pre>
</div></p>

<p>Now some normal text in between the haskell blocks, before we give haskell highlighting a run for its money.</p>

<p><div>
<pre class="haskell" style="font-family:monospace;"><span style="color: #339933; font-weight: bold;">&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:and"><span style="font-weight: bold;">and</span></a> <span style="color: #339933; font-weight: bold;">.</span> more <span style="color: #339933; font-weight: bold;">.</span> haskell <span style="color: #339933; font-weight: bold;">$</span> <span style="color: green;">&#91;</span><span style="color: red;">1</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">3</span><span style="color: green;">&#93;</span>
<span style="color: #339933; font-weight: bold;">&gt;</span> main <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"><span style="font-weight: bold;">print</span></a><span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span style="font-weight: bold;">take</span></a>`<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id"><span style="font-weight: bold;">id</span></a>`<span style="color: red;">20</span><span style="color: #339933; font-weight: bold;">$</span>fix<span style="color: #339933; font-weight: bold;">$</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">&lt;$&gt;</span><span style="color: green;">&#40;</span>:<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">&lt;*&gt;</span><span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>:<span style="color: green;">&#91;</span><span style="color: green;">&#93;</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">=&lt;&lt;</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">*</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">*</span><span style="color: red;">2</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">$</span><span style="color: red;">1</span> <span style="color: #5d478b; font-style: italic;">-- print an interesting sequence</span></pre>
</div></p>

<p>End of test.</p>

<p>Anyway, here&#8217;s the <a href="http://olsner.se/wp-content/uploads/2008/02/markdown-lhs.patch">patch for markdown.php</a> (you&#8217;ll also need to cut-n-paste the highlight_helper.php file from <a href="http://www.dougalstanton.net/blog/index.php/2007/12/15/syntax-highlighting-with-markdown-in-wordpress">Dougal Stanton&#8217;s blog</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://olsner.se/2008/02/05/literate-haskell-blogging/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thue in Haskell</title>
		<link>http://olsner.se/2008/01/27/thue-in-haskell/</link>
		<comments>http://olsner.se/2008/01/27/thue-in-haskell/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 21:27:26 +0000</pubDate>
		<dc:creator>olsner</dc:creator>
				<category><![CDATA[Esolangs]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Thue]]></category>

		<guid isPermaLink="false">http://blog.olsner.se/?p=7</guid>
		<description><![CDATA[Yesterday, I wrote a Thue implementation in Haskell. At this point, the implementation is painfully slow (about 35 minutes to run the brainfuck &#8220;Hello World!&#8221; through the BF Thue interpreter on my MacBook, as compared to about 4 minutes for the python Thue implementation run in python 2.5.1). I&#8217;m thinking I should a) should use [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I wrote a <a href="http://esolangs.org/wiki/Thue">Thue</a> implementation in Haskell. At this point, the implementation is painfully slow (about 35 minutes to run the brainfuck &#8220;Hello World!&#8221; through the BF Thue interpreter on my MacBook, as compared to about 4 minutes for the <a href="http://catseye.tc/projects/thue/src/thue.py">python Thue implementation</a> run in python 2.5.1). I&#8217;m thinking I should a) should use ByteString&#8217;s instead of String, and b) use some smarter algorithm for matching the rules (instead of <code>untilDone (foldl applyRule input rules)</code>, it&#8217;d be something more like compiling an automaton out of all rules and <code>untilDone (run automaton)</code>). By reducing the number of rules (eliminating the 50 or so #::=# rules, which are comments in idiomatic Thue but don&#8217;t strictly need special processing), I could squeeze about twice the performance out of it &#8211; this optimization brought the execution time down to 35 minutes. I need at least 10x the performance before this program is anything to brag about!</p>

<p>Another idea for the future is to implement parallel Thue by splitting up the state and then replacing in the parts until no replacements can be done in parallel, then running a few iterations serially on the whole state. You could also just synchronize once and move the split-point &#8211; which would eliminate the problem of deciding when to start going parallell again since you&#8217;d never really go serial. With the language designed to allow random replacement order, any valid Thue program already contains the synchronization needed to make it evaluate the right thing and e.g. output things in the correct order, so this is perfectly safe provided you have a correct implementation and correct programs.</p>

<p>Although it&#8217;s fun to make things go fast, I think parallel Thue would be much more interesting as it might even be something that&#8217;s never been done before!</p>

<p>Anyway, if you want to try it out, here&#8217;s my <a href="http://darcs.olsner.se/Thue">Thue darcs repository</a>, containing the haskell source and the <a href="http://fvdp.homestead.com/files/eso_index.html#BFThue">BF interpreter in Thue</a> with the BF Hello world program I&#8217;ve been using for testing. It should take exactly 287197 steps (and heaps of time) to complete the execution and print <code>"Hello world!\n"</code> as a series of binary numbers separated by underscores.</p>
]]></content:encoded>
			<wfw:commentRss>http://olsner.se/2008/01/27/thue-in-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

