<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-17056150</id><updated>2024-03-13T15:09:13.691+00:00</updated><title type='text'>malcolm</title><subtitle type='html'>Haskell Programmer</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default?alt=atom'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-17056150.post-1141670936107270785</id><published>2017-02-13T19:51:00.001+00:00</published><updated>2017-02-13T19:51:27.154+00:00</updated><title type='text'>We are hiring Functional Programmers.</title><content type='html'>&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;The Modelling and Analytics Group was the original introducer of Functional Programming (especially Haskell) to the Financial Markets business of Standard Chartered Bank, and although there are now several other teams who contribute to our large codebase and who are also hiring, we now have some vacancies in the Core team. &amp;nbsp;Please think about applying!&lt;/span&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0.0001pt;&quot;&gt;
&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Job Description:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0.0001pt;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Join the Modeling and Analytics’ Core team, part of Financial Markets Front Office, in Singapore or London.&lt;/li&gt;
&lt;li&gt;Apply Functional Programming concepts to the design and implementation of the unified bank’s Analytics library.&lt;/li&gt;
&lt;li&gt;Support infrastructure requests from the Quant group, flow trading desks, structured trading desks &amp;amp; structuring worldwide.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0.0001pt;&quot;&gt;
&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Candidate qualifications:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; border-spacing: 0px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0.0001pt;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Master or PhD in Computer Science, with a focus among: functional programming, language &amp;amp; compiler design, efficient data processing.&lt;/li&gt;
&lt;li&gt;Excellent programming skills in one of the major statically typed functional languages (ideally Haskell), and preferably exhibited by academic output (research / teaching) or open-source development.&lt;/li&gt;
&lt;li&gt;Proficiency with C/C++ and debugging / performance tuning tools is a strong advantage.&lt;/li&gt;
&lt;li&gt;Good communication skills required for interactions with other team members and with trading desks.&lt;/li&gt;
&lt;li&gt;Familiarity with financial markets is a plus but not required.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;u&gt;How to apply:&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;In the first instance, send your CV to Raphael.Montelatici@sc.com&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/1141670936107270785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/1141670936107270785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/1141670936107270785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/1141670936107270785'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2017/02/we-are-hiring-functional-programmers.html' title='We are hiring Functional Programmers.'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-904208490384521005</id><published>2009-09-21T21:55:00.003+01:00</published><updated>2009-09-21T21:58:38.724+01:00</updated><title type='text'>Haskell Symposium 2009 - videos now online</title><content type='html'>Videos from the recent Haskell Symposium 2009, held in Edinburgh, are now edited and uploaded to&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.vimeo.com/album/128530&quot;&gt;http://www.vimeo.com/album/128530&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The original programme of talks is at &lt;a href=&quot;http://www.haskell.org/haskell-symposium/2009/schedule.html&quot;&gt;http://www.haskell.org/haskell-symposium/2009/schedule.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/904208490384521005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/904208490384521005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/904208490384521005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/904208490384521005'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2009/09/haskell-symposium-2009-videos-now.html' title='Haskell Symposium 2009 - videos now online'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-7027337188132922025</id><published>2009-02-02T16:36:00.002+00:00</published><updated>2009-02-02T16:42:16.415+00:00</updated><title type='text'>HUGE Data but small Programs</title><content type='html'>The &lt;a href=&quot;http://www-users.cs.york.ac.uk/~malcolm/padl09_slides.pdf&quot;&gt;slides for our PADL&#39;09 talk&lt;/a&gt;, about language design (of DSLs) as a strategy for solving visualisation problems, are now available online.  The &quot;programs&quot; for exploratory combinations of visualisations are small.  So is the Haskell implementation behind it all.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/7027337188132922025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/7027337188132922025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/7027337188132922025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/7027337188132922025'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2009/02/huge-data-but-small-programs.html' title='HUGE Data but small Programs'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-316732848474062833</id><published>2009-01-26T16:10:00.003+00:00</published><updated>2009-01-26T16:17:32.220+00:00</updated><title type='text'>codec implementations</title><content type='html'>Many years ago, Jeroen Fokker wrote a &lt;a href=&quot;http://people.cs.uu.nl/jeroen/article/jpeg/index.html&quot;&gt;&quot;Functional Specification of the JPEG algorithm, and an Implementation for Free&quot;&lt;/a&gt;.  It was great on clarity - really helped me to understand the codec - but totally sucked on performance.  With all the recent activity in making pure Haskell libraries with decent speed, utilising fusion and other optimisation techniques, I&#39;m wondering whether it is time to revisit that paper, and see whether we can keep the high-level specificational style, but do rather better on all that number-crunching.  In fact, after JPEG, why not take a look at something more challenging, like specifying/implementing the H.264 or Ogg Theora video codecs?</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/316732848474062833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/316732848474062833' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/316732848474062833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/316732848474062833'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2009/01/codec-implementations.html' title='codec implementations'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-1545491934810804393</id><published>2007-10-09T17:40:00.000+01:00</published><updated>2007-10-09T17:47:36.449+01:00</updated><title type='text'>Haskell Workshop 2007 videos</title><content type='html'>Videos of all this year&#39;s Haskell Workshop talks, demos, and discussion, are now available: ̄&lt;a href=&quot;http://www.ludd.ltu.se/~pj/hw2007/HaskellWorkshop.html&quot;&gt;here&lt;/a&gt;.  The first location we hosted these at chewed through 100Gb of transfers in 24 hours, so go easy on the current host won&#39;t you?  The videos are in QuickTime (H.264 + AAC audio, 320x240, about 8-12 fps), and are about 120-150Mb each.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/1545491934810804393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/1545491934810804393' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/1545491934810804393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/1545491934810804393'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2007/10/haskell-workshop-2007-videos.html' title='Haskell Workshop 2007 videos'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-8271022742368371825</id><published>2007-07-11T21:30:00.000+01:00</published><updated>2007-07-12T13:50:27.330+01:00</updated><title type='text'>HsColour gets a new backend</title><content type='html'>This morning, people in #haskell were playing with colours and bold/underline style formatting in the IRC channel, having just discovered it was possible.  Mauke took HsColour&#39;s output for ANSI terminal codes and wrote a perl script to translate it into IRC colour codes instead.  Now, how could I live with that? - munging the output of a beautiful haskell program using a perl script that looks like pure line noise!&lt;br /&gt;&lt;br /&gt;Hence, the emergence of a new pure haskell backend for HsColour: the -mirc formatting flag.  It&#39;s actually really easy to create new backends, hence the growth from the original 2 (-tty and -html) to 5 formats now.  In fact, it was 70 lines of haskell, against 89 lines of perl.  Smaller, more beautiful, more readable, more maintainable.&lt;br /&gt;&lt;br /&gt;And only yesterday, &lt;a href=&quot;http://notvincenz.blogspot.com/&quot;&gt;Christophe Poucet&lt;/a&gt; contributed another new feature to HsColour: the -lit flag for literate code.  Obviously, you don&#39;t really want syntax highlighting on the main parts of the document, just in the embedded code fragments.  So with a little cannibalisation of the unlit module in the Haskell 1.2 Report, voila, HsColour now only colourises the code, not the document.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/8271022742368371825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/8271022742368371825' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/8271022742368371825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/8271022742368371825'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2007/07/hscolour-gets-new-backend.html' title='HsColour gets a new backend'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-114647651401282397</id><published>2006-05-01T10:06:00.000+01:00</published><updated>2006-05-01T10:41:54.023+01:00</updated><title type='text'>Register-based bytecode</title><content type='html'>I blogged a few months ago about a student who was looking at turning the standard stack-based bytecode into a register-based variant.  Well, now the results are in, and they look pretty good.  Just to recap, the plan was to take &lt;a href=&quot;http://www-users.cs.york.ac.uk/~ndm/yhc/&quot;&gt;Yhc&lt;/a&gt;&#39;s backend bytecode (based on the spineless G-machine); to define a new bytecode that implements the same operations, using machine registers instead of a stack for temporary storage; to translate from one bytecode format to the other (including a register allocator); and to implement the corresponding runtime interpreter to execute the bytecodes.&lt;br /&gt;&lt;br /&gt;The implementation proceeded in stages, at first using an array to represent a set of registers, then later using a cunning despatch mechanism to get hold of real registers.  At this point, performance of the new system was about the same as that of the old system.  But the cool thing is that register-based code allows more peephole-optimisation &lt;br /&gt;opportunities.  You can re-order instructions, provided they do not touch the same registers, and this code motion brings together pairs of instructions which can cancel each other out, or be fused into a different instruction that is cheaper.  Alex also did some extensive profiling to discover common instruction/instruction pairings, and instruction/register pairings, and created specialised versions of those recurring operations.  (This kind of profiling had already been done on the original nhc98/yhc stack-based bytecode, gaining about 25% in speed. The naive translation to register code actually threw away all that optimisation work, aiming initially for a simple, regular instruction set.)  &lt;br /&gt;&lt;br /&gt;So with some optimisation phases added, the register-based bytecode now runs up to 2x faster than stack-based code.  There are more potential optimisations waiting in the wings too, although Alex will not have time to implement these.&lt;br /&gt;&lt;br /&gt;One of the interesting negative results is that the first translation scheme ended up making the bytecode size larger (about twice the size on average per program), but that this made the &quot;hello world&quot; program 7x slower!  Since yhc loads the program code dynamically at runtime, what this means is that there is a non-linear relationship between file size and loading time.  But this is only really a concern for very short-running programs: above 1 second, the gains in running time outweigh the losses at loading time.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/114647651401282397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/114647651401282397' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/114647651401282397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/114647651401282397'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2006/05/register-based-bytecode.html' title='Register-based bytecode'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-113822819242664666</id><published>2006-01-25T22:21:00.000+00:00</published><updated>2006-01-25T22:29:52.436+00:00</updated><title type='text'>Improvements to HsColour</title><content type='html'>After my last post about &lt;a href=&quot;http://www.cs.york.ac.uk/fp/darcs/hscolour/&quot;&gt;HsColour&lt;/a&gt;, Neil stepped up to the plate and implemented a CSS backend, to complement the existing HTML-3.2 and ANSI terminal code outputs.  More recently, extensions have been added to Haddock, the Haskell library auto-documentation tool, that allow the generated documentation to link to a wiki for user comments, to a bug-tracker for bug reports, and to the original source code for reference.&lt;br /&gt;&lt;br /&gt;This is an obvious place for HsColour to fit in.  Why display just raw source code on the web, when you can colourise it as an aid to readability?  So there is a clear further requirement now.  Ideally, Haddock should link to each individual function definition, not just to the top of the module that contains it.  So, the HTML generated by HsColour needs to embed an anchor tag with each definition, so that the &lt;tt&gt;page.html#anchor&lt;/tt&gt; syntax for references will work.&lt;br /&gt;&lt;br /&gt;But there is a difficulty with extending HsColour to do this. Colourisation is a simple &lt;em&gt;lexical&lt;/em&gt; problem.  To find the defining occurrence of a function identifier (or datatype, or class), you really require a &lt;em&gt;parser&lt;/em&gt;.  Although simple top-level definitions have the function identifier starting in the leftmost column, what about (for instance) an infix-style definition, with an arbitrarily deep pattern on the left of the identifier you are trying to find?&lt;br /&gt;&lt;br /&gt;It turns out that one &lt;em&gt;can&lt;/em&gt; in fact write a finite state automaton to find the defining occurrences.  It is rather like a complex lexer, but I reckon it is still more lightweight than either writing a full parser, or stealing one from elsewhere.  I have an initial design, and I&#39;m aiming for less than 150 lines of extra code.  Work in progress is available in the darcs repository.&lt;br /&gt;&lt;br /&gt;Meanwhile, the &lt;a href=&quot;http://www.cse.ogi.edu/~hallgren/Programatica/tools/pfe.cgi&quot;&gt;Programatica&lt;/a&gt; project has solved the same problem very nicely.  Their Hs2Html tool is integrated with the entire compiler front-end, so they have, not only a parser, but a full module-import resolution phase as well.  This means they can generate HTML with cross-links from every /use/ of an identifier to its definition, even across source files.  Extremely useful, and very navigable.  The downside is that it is a rather heavy-weight mechanism - the tool needs to have every module available (including the Prelude) or it can&#39;t finish.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/113822819242664666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/113822819242664666' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113822819242664666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113822819242664666'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2006/01/improvements-to-hscolour.html' title='Improvements to HsColour'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-113407538354819213</id><published>2005-12-08T20:41:00.000+00:00</published><updated>2005-12-08T20:56:23.556+00:00</updated><title type='text'>Colourising code</title><content type='html'>If anyone is interesting in colourising Haskell code to paste into HTML on your blog (as in my previous entry below), it was done with a simple Haskell program (of course).  &lt;a href=&quot;ftp://ftp.cs.york.ac.uk/pub/haskell/contrib/hscolour-1.1.tar.gz&quot;&gt;HsColour&lt;/a&gt; is a little script I knocked up a few years back.  It uses an intermediate mini-language of highlighting styles, and currently has two backends, one for HTML and another for ANSI terminal screen codes.  I&#39;m sure it would be simple to add other backend rendering formats - maybe CSS - with a tiny bit of effort.  If you do modify it, or otherwise find it useful, please let me know.&lt;br /&gt;&lt;br /&gt;The history of HsColour is vaguely interesting, because it was essentially a spin-off of my (winning) entry in the 0th International Obfuscated Haskell Contest - &lt;a href=&quot;ftp://ftp.cs.york.ac.uk/pub/haskell/contrib/remorse-1.0.tar.gz&quot;&gt;remorse&lt;/a&gt;.  If you haven&#39;t seen remorse before, I&#39;ll try not to spoil the fun of discovering it, but suffice to say, it requires a mini-lexer for Haskell code, which I ripped out and re-used in HsColour.  Don&#39;t worry - that isn&#39;t the obfuscated bit.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/113407538354819213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/113407538354819213' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113407538354819213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113407538354819213'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/12/colourising-code.html' title='Colourising code'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-113301726218243351</id><published>2005-11-26T10:04:00.000+00:00</published><updated>2005-11-26T15:01:02.213+00:00</updated><title type='text'>Replacement for Read class</title><content type='html'>So here&#39;s something that has annoyed me for ages.  The standard Read class in Haskell.  OK, so you can derive it automatically at the same time as you derive Show.  But if you want to write your own instance of Show to make your data printer even slightly out of the ordinary, then you&#39;ll have to write your own instance of Read to match it.  Writing an instance of Read is &lt;i&gt;far&lt;/i&gt; more complicated than it ought to be.  The list comprehension style is OK, but having to plumb the trailing unconsumed input all the way through it is rather tedious and offputting.  This plumbing problem was solved ages ago when someone invented monadic parser combinators.&lt;br /&gt;&lt;br /&gt;But wait, there&#39;s another annoying aspect of Read as well:  rubbish error-handling.  If anything at all goes wrong - for instance you edit the string produced by show and forget a comma, or you write your instance of Read incorrectly -  then boom, your program crashes with the error &quot;no parse&quot;.  No opportunity to catch the error and do something graceful.  No indication of what actually went wrong.  It just dies and leaves you in the dark.  But wait, the monadic parser combinator people solved &lt;i&gt;that&lt;/i&gt; problem eons ago as well!&lt;br /&gt;&lt;br /&gt;[Historical note: the Read class was originally defined (actually known as the Text class) long before any of us FP people even knew what a monad was, so we can&#39;t really blame the Haskell committee.  It was a reasonable choice at the time.]&lt;br /&gt;&lt;br /&gt;Now, I&#39;m aware that Koen Claessen and Simon PJ have come up with a replacement for Read called ReadP, based on monadic parser combinators.  It is even used internally by GHC when you derive Read.  But the trouble is, their scheme is designed to get better efficiency and avoid backtracking, not to improve the error handling.  The interface to the class Read remains the same.  So my thought is, why not propose a complete replacement of the Read class, interface and all?  Here&#39;s what I came up with:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;font color=Blue&gt;-- | First a general parser monad, t = token type, a = result value.&lt;/font&gt;&lt;br /&gt;&lt;font color=Blue&gt;--   Errors are returned through the Either type.&lt;/font&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;newtype&lt;/u&gt;&lt;/font&gt; Parser t a &lt;font color=Red&gt;=&lt;/font&gt; P &lt;font color=Cyan&gt;(&lt;/font&gt;&lt;font color=Red&gt;[&lt;/font&gt;t&lt;font color=Red&gt;]&lt;/font&gt; &lt;font color=Red&gt;-&amp;gt;&lt;/font&gt; &lt;font color=Cyan&gt;(&lt;/font&gt;Either String a&lt;font color=Cyan&gt;,&lt;/font&gt; &lt;font color=Red&gt;[&lt;/font&gt;t&lt;font color=Red&gt;]&lt;/font&gt;&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;instance&lt;/u&gt;&lt;/font&gt; Functor &lt;font color=Cyan&gt;(&lt;/font&gt;Parser t&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;instance&lt;/u&gt;&lt;/font&gt; Monad   &lt;font color=Cyan&gt;(&lt;/font&gt;Parser t&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=Blue&gt;-- | Apply a parser to an input token sequence.&lt;/font&gt;&lt;br /&gt;runParser &lt;font color=Red&gt;::&lt;/font&gt; Parser t a &lt;font color=Red&gt;-&amp;gt;&lt;/font&gt; &lt;font color=Red&gt;[&lt;/font&gt;t&lt;font color=Red&gt;]&lt;/font&gt; &lt;font color=Red&gt;-&amp;gt;&lt;/font&gt; &lt;font color=Cyan&gt;(&lt;/font&gt;Either String a&lt;font color=Cyan&gt;,&lt;/font&gt; &lt;font color=Red&gt;[&lt;/font&gt;t&lt;font color=Red&gt;]&lt;/font&gt;&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=Blue&gt;-- | A TextParser is a specialisation of the standard parser monad&lt;/font&gt;&lt;br /&gt;&lt;font color=Blue&gt;--   over character strings.&lt;/font&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;type&lt;/u&gt;&lt;/font&gt; TextParser a &lt;font color=Red&gt;=&lt;/font&gt; Parser Char a&lt;br /&gt;&lt;br /&gt;&lt;font color=Blue&gt;-- | The class @Parse@ is a replacement for @Read@.&lt;/font&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;class&lt;/u&gt;&lt;/font&gt; Parse a &lt;font color=Green&gt;&lt;u&gt;where&lt;/u&gt;&lt;/font&gt;&lt;br /&gt;    parse     &lt;font color=Red&gt;::&lt;/font&gt; TextParser a&lt;br /&gt;    parseList &lt;font color=Red&gt;::&lt;/font&gt; TextParser &lt;font color=Red&gt;[&lt;/font&gt;a&lt;font color=Red&gt;]&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=Blue&gt;-- | If there already exists a Read instance for a type, then we can make&lt;/font&gt;&lt;br /&gt;&lt;font color=Blue&gt;--   a Parser for it.&lt;/font&gt;&lt;br /&gt;parseByRead &lt;font color=Red&gt;::&lt;/font&gt; Read a &lt;font color=Red&gt;=&amp;gt;&lt;/font&gt; String &lt;font color=Red&gt;-&amp;gt;&lt;/font&gt; TextParser a&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The monadic combinators still provide back-tracking, through a standard choice operator, but the key thing is that the caller of &lt;tt&gt;runParser&lt;/tt&gt; gets to see whether there was an error, allowing it to do something sensible, and if there was an error, there is an explanatory message to go with it.&lt;br /&gt;&lt;br /&gt;Also, defining an instance of the Parse class is dead easy.  Here&#39;s an example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;data&lt;/u&gt;&lt;/font&gt; Shape &lt;font color=Red&gt;=&lt;/font&gt;&lt;br /&gt;    Circle  ShapeStyle Double&lt;br /&gt;  &lt;font color=Red&gt;|&lt;/font&gt; Polygon ShapeStyle &lt;font color=Red&gt;[&lt;/font&gt;DoublePoint&lt;font color=Red&gt;]&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;instance&lt;/u&gt;&lt;/font&gt; Parse Shape &lt;font color=Green&gt;&lt;u&gt;where&lt;/u&gt;&lt;/font&gt;&lt;br /&gt;  parse &lt;font color=Red&gt;=&lt;/font&gt; oneOf&lt;br /&gt;      &lt;font color=Red&gt;[&lt;/font&gt; &lt;font color=Green&gt;&lt;u&gt;do&lt;/u&gt;&lt;/font&gt;&lt;font color=Cyan&gt;{&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;Circle&quot;&lt;/font&gt;&lt;font color=Cyan&gt;;&lt;/font&gt;  return Circle &lt;font color=Cyan&gt;`apply`&lt;/font&gt; parse &lt;font color=Cyan&gt;`apply`&lt;/font&gt; parse &lt;font color=Cyan&gt;}&lt;/font&gt;&lt;br /&gt;      &lt;font color=Cyan&gt;,&lt;/font&gt; &lt;font color=Green&gt;&lt;u&gt;do&lt;/u&gt;&lt;/font&gt;&lt;font color=Cyan&gt;{&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;Polygon&quot;&lt;/font&gt;&lt;font color=Cyan&gt;;&lt;/font&gt; return Polygon &lt;font color=Cyan&gt;`apply`&lt;/font&gt; parse &lt;font color=Cyan&gt;`apply`&lt;/font&gt; parse &lt;font color=Cyan&gt;}&lt;/font&gt;&lt;br /&gt;      &lt;font color=Red&gt;]&lt;/font&gt; &lt;font color=Cyan&gt;`adjustErr`&lt;/font&gt; &lt;font color=Cyan&gt;(&lt;/font&gt;&lt;font color=Cyan&gt;++&lt;/font&gt;&lt;font color=Magenta&gt;&quot;\nexpected a Shape (Circle,Polygon)&quot;&lt;/font&gt;&lt;font color=Cyan&gt;)&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Even dealing with field notation is rather simple as well:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;font color=Green&gt;&lt;u&gt;data&lt;/u&gt;&lt;/font&gt; ShapeStyle &lt;font color=Red&gt;=&lt;/font&gt; ShapeStyle&lt;br /&gt;    &lt;font color=Cyan&gt;{&lt;/font&gt; styleStrokeWidth  &lt;font color=Red&gt;::&lt;/font&gt; Int&lt;br /&gt;    &lt;font color=Cyan&gt;,&lt;/font&gt; styleFill         &lt;font color=Red&gt;::&lt;/font&gt; Colour&lt;br /&gt;    &lt;font color=Cyan&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color=Green&gt;&lt;u&gt;instance&lt;/u&gt;&lt;/font&gt; Parse ShapeStyle &lt;font color=Green&gt;&lt;u&gt;where&lt;/u&gt;&lt;/font&gt;&lt;br /&gt;  parse &lt;font color=Red&gt;=&lt;/font&gt; &lt;font color=Green&gt;&lt;u&gt;do&lt;/u&gt;&lt;/font&gt;&lt;font color=Cyan&gt;{&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;ShapeStyle&quot;&lt;/font&gt;&lt;br /&gt;            &lt;font color=Cyan&gt;;&lt;/font&gt; return ShapeStyle&lt;br /&gt;                &lt;font color=Cyan&gt;`discard`&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;{&quot;&lt;/font&gt; &lt;font color=Cyan&gt;`apply`&lt;/font&gt; field &lt;font color=Magenta&gt;&quot;styleStrokeWidth&quot;&lt;/font&gt;&lt;br /&gt;                &lt;font color=Cyan&gt;`discard`&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;,&quot;&lt;/font&gt; &lt;font color=Cyan&gt;`apply`&lt;/font&gt; field &lt;font color=Magenta&gt;&quot;styleFill&quot;&lt;/font&gt;&lt;br /&gt;                &lt;font color=Cyan&gt;`discard`&lt;/font&gt; isWord &lt;font color=Magenta&gt;&quot;}&quot;&lt;/font&gt;&lt;br /&gt;            &lt;font color=Cyan&gt;}&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I&#39;ve been using this Parse class for a few weeks now, and it is a big improvement over Read, so much so that I&#39;m thinking of proposing it (or something similar) for Haskell-prime, the new version of the language standard.  The actual set of parser combinators used to underlie the class is not so important.  I&#39;m using my own recently developed set, called Text.ParserCombinators.Poly, based originally on the Hutton-Meijer combinators from 1996.  But that is just because I&#39;m most familiar with them.  I&#39;m sure Daan Leijen&#39;s Parsec combinators would be just as good a choice.&lt;br /&gt;&lt;br /&gt;For now, both Poly and TextParser are distributed in &lt;a href=&quot;http://www.cs.york.ac.uk/fp/HaXml-1.14&quot;&gt;HaXml-1.14&lt;/a&gt;, (also available in fptools CVS) and will no doubt continue to evolve over the next few weeks.  Once they are fairly settled, I might distribute them as a separate package, not tied to HaXml.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/113301726218243351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/113301726218243351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113301726218243351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113301726218243351'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/11/replacement-for-read-class.html' title='Replacement for Read class'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-113225885500383564</id><published>2005-11-17T20:02:00.000+00:00</published><updated>2005-11-17T20:20:55.013+00:00</updated><title type='text'>Bytecode experiments</title><content type='html'>I have another undergraduate starting a project this week.  Originally he was to look at replacing the spineless G-machine bytecode used in &lt;a href=&quot;http://haskell.org/nhc98&quot;&gt;nhc98&lt;/a&gt; with a three-address instruction code.  That is still the plan, only now he might use &lt;a href=&quot;http://www.cs.york.ac.uk/~ndm/yhc&quot;&gt;yhc&lt;/a&gt; as a platform instead.&lt;br /&gt;&lt;br /&gt;The idea is simple.  Standard G-machine instructions use the stack heavily as temporary storage.  But this is potentially bad for performance, because of all the memory accesses.  Using registers for temporary storage would potentially be much faster.  This is what native-code compilers do of course.  But I would like to continue to have a portable bytecode, running on a small interpretive virtual machine.  So part of the problem will be to map temporaries to real registers in the VM itself.&lt;br /&gt;However I expect that to be relatively straightforward, and the major work will be defining and generating a register-based bytecode.  I&#39;m thinking of translating the already-generated G-code to register code by simulating the stack.&lt;br /&gt;&lt;br /&gt;Ultimately, I&#39;m hoping for a decent speed-up, maybe 2x or better.  But I guess there are quite a few pitfalls that could mean we only an improvement of say 20%.  Or maybe it will go spectacularly well, and we&#39;ll get 3x improvement.  We&#39;ll find out in a few months time.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/113225885500383564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/113225885500383564' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113225885500383564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113225885500383564'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/11/bytecode-experiments.html' title='Bytecode experiments'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-113066659189987970</id><published>2005-10-30T09:39:00.000+00:00</published><updated>2005-10-30T10:03:11.916+00:00</updated><title type='text'>Mentioned on Lambda-the-Ultimate</title><content type='html'>Thanks to &lt;a href=&quot;http://lambda-the-ultimate.org/&quot;&gt;Lambda the Ultimate&lt;/a&gt; for pointing people who are interested in programming languages over to my blog.  I suddenly noticed that lots of the things I talk about do not have hyperlinks to allow the interested party to find out more.  Since I don&#39;t know how to go back and edit old posts, I thought I&#39;d give a bunch of links here instead, whilst trying to be more disciplined in future.&lt;br /&gt;&lt;br /&gt;The &lt;a href=&quot;http://haskell.org/&quot;&gt;Haskell&lt;/a&gt; language.&lt;br /&gt;The &lt;a href=&quot;http://haskell.org/nhc98&quot;&gt;nhc98&lt;/a&gt; compiler.&lt;br /&gt;The &lt;a href=&quot;http://haskell.org/hat&quot;&gt;Hat&lt;/a&gt; HAskell Tracer/debugger.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;ftp://ftp.cs.york.ac.uk/pub/malcolm/fesca05.html&quot;&gt;Failure Propagation and Transformation Calculus&lt;/a&gt;.&lt;br /&gt;&lt;a href=&quot;http://www.cs.uu.nl/dazzle/&quot;&gt;Dazzle&lt;/a&gt; Bayesian analysis tool.&lt;br /&gt;&lt;a href=&quot;http://haskell.org/Blobs&quot;&gt;Blobs&lt;/a&gt; diagram editor (webpage not yet live).&lt;br /&gt;&lt;a href=&quot;http://wxhaskell.sourceforge.net/&quot;&gt;wxHaskell&lt;/a&gt; cross-platform GUI toolkit.&lt;br /&gt;&lt;a href=&quot;http://www.cs.uu.nl/~daan/hw2005/&quot;&gt;Haskell Workshop&lt;/a&gt; 2005.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://haskell.org/HaXml&quot;&gt;HaXml&lt;/a&gt; libraries and tools.&lt;br /&gt;&lt;a href=&quot;http://www.cs.york.ac.uk/fp/HaXml-1.14&quot;&gt;Prerelease (1.14)&lt;/a&gt; of how HaXml-2 is shaping up.&lt;br /&gt;&lt;a href=&quot;http://repetae.net/~john/computer/haskell/DrIFT/&quot;&gt;DrIFT&lt;/a&gt; type-directed preprocessor.&lt;br /&gt;&lt;a href=&quot;http://www.fh-wedel.de/~si/HXmlToolbox/&quot;&gt;Haskell Xml Toolbox&lt;/a&gt; from Uwe Schmidt.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/113066659189987970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/113066659189987970' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113066659189987970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/113066659189987970'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/10/mentioned-on-lambda-ultimate.html' title='Mentioned on Lambda-the-Ultimate'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-112972563747475299</id><published>2005-10-19T12:19:00.000+01:00</published><updated>2005-10-19T13:40:37.486+01:00</updated><title type='text'>O&#39;Caml vs Haskell - is a strict language faster?</title><content type='html'>A couple of years ago I had a student doing a project to compare Haskell with Clean for performance.  He developed a translator (&lt;a href=&quot;http://www.cs.york.ac.uk/~mfn/hacle&quot;&gt;Hacle&lt;/a&gt;) from one language to the other, so the same program could be directly compared for measurement.  The initial results were promising - it looked like Clean always produced faster code.  But a more careful comparison over more test data showed a mixed picture, some were faster, some slower.  Because the languages are so similar (both lazy) this seemed like a good test of one compiler team&#39;s skills against another.&lt;br /&gt;&lt;br /&gt;So this year, I have a student doing something similar, only with O&#39;Caml and Haskell.  Again, there will be a translator from Haskell, and again we are looking to see if Xavier is just a better hacker than SPJ.  :-)  However, there is more to it this time.  To what extent is laziness a time loss, or a time gain?  The idea is that there are two possible translations from Haskell to O&#39;Caml - one preserving the structure and semantics of the code, which is then simply evaluated strictly instead of lazily; and the other simulating non-strictness in O&#39;Caml, so the code has the same termination behaviour as well as its semantics.  I think everyone would expect O&#39;Caml to win the first challenge, because of its reputation for very fast code.  Even so, I suspect there may be cases where laziness is a better strategy, and Haskell might just do well.  But how about lazy O&#39;Caml vs lazy Haskell?  That&#39;s the interesting question for me.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/112972563747475299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/112972563747475299' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112972563747475299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112972563747475299'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/10/ocaml-vs-haskell-is-strict-language.html' title='O&#39;Caml vs Haskell - is a strict language faster?'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-112915058341767217</id><published>2005-10-12T21:24:00.000+01:00</published><updated>2005-10-12T21:56:23.423+01:00</updated><title type='text'>unifying Haskell2Xml and Xml2Haskell</title><content type='html'>So, there I was, hacking on Blobs (see below), and I realised that the file storage format for these diagrams is XML, so naturally Arjan has used the HaXml library for writing/reading these files.  Great.  But wait, what do I see?  Even though all the internal data structures to be stored are defined in Haskell, he hasn&#39;t used the Haskell2Xml class, which can be handily derived for you by DrIFT.  No, he uses the low-level generic XML parser/printer, and then hand-converts from the generic tree into and from his own data structures.  Why ever did he do that?  And then the first thing hit me.  The Haskell2Xml methods return a &quot;Maybe a&quot; type.  For production software, that simply isn&#39;t good enough.  If the input fails to parse, then the developer is jolly well going to want an explanation of why not.  The low-level generic parser gives back decent error messages if it finds a problem.  But the high-level typeful parser does not.  And then the second thing hit me.  The Haskell2Xml method is indeed a &lt;i&gt;parser&lt;/i&gt;.  It parses the generic tree into a user-defined typeful tree.  Yet it isn&#39;t written as one.  Even though the low-level parser is constructed with nice combinators, Haskell2Xml doesn&#39;t use them, but rolls its own ad hoc solution.&lt;br /&gt;&lt;br /&gt;The realisation of what I had to do was swift and immediately convincing.  I had to replace HaXml&#39;s Haskell2Xml class with a true parser combinator framework.  Not only that, but there is a corresponding class Xml2Haskell, derived not by DrIFT, but by the Dtd2Haskell tool, which uses an XML DTD as the source of the data structures.  And yes, that too is really a parser, but was not written as one.  So yes, that too needed to be rewritten.&lt;br /&gt;&lt;br /&gt;In fact, come to think of it, why are there two classes anyway?  Surely if you want to parse some XML to a typeful representation, then it is the same job, no matter where the types were originally defined.  OK, so the actual instances of the class will be different depending on whether you use DrIFT or Dtd2Haskell to write them, but so what?  In fact, won&#39;t there be circumstances in which you want to mix code of different origins - to dump a Haskell-derived data structure into the middle of a document with an open DTD, or vice versa?  Having two separate classes would be unpleasant and unnecessary.&lt;br /&gt;&lt;br /&gt;And thus the tale started.  HaXml-2 will shortly (I hope) see the light of day.  The original three kinds of parsing techniques will be reduced to one - a new set of combinators - and the parsers written with them will layer on top of one another.  The generic tree parser is on the bottom, and the typeful tree parser on top, but both now using the same set of monadic combinators.  It is so much more aesthetically pleasing.  Not to mention giving far better error messages than before, so more practically useful too.&lt;br /&gt;&lt;br /&gt;P.S. The Haskell Xml Toolbox from Uwe Schmidt got a new release today.  Apparently it has Arrows now.  Must look into that.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/112915058341767217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/112915058341767217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112915058341767217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112915058341767217'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/10/unifying-haskell2xml-and-xml2haskell.html' title='unifying Haskell2Xml and Xml2Haskell'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-112897152350480324</id><published>2005-10-10T19:42:00.000+01:00</published><updated>2005-10-10T20:12:03.510+01:00</updated><title type='text'>Completed draft 0 of interactive diagramming tool.</title><content type='html'>&lt;a href=&quot;http://photos1.blogger.com/blogger/4326/1635/1600/blobs%20picture.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;http://photos1.blogger.com/blogger/4326/1635/400/blobs%20picture.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;University term has just started today, so I&#39;m feeling the potential pressure of getting snowed under with teaching commitments, so this was my last real chance to get some significant coding finished on my most recent tool project.  Over the last couple of years, I&#39;ve been developing the theory of FPTC - Failure Propagation and Transformation Calculus.  It is a method for analysing safety-critical systems designs that consist of both software and hardware components.  Essentially, you determine the failure modes of each component and communications mechanism, in response to any failures in their environment.  So then you annotate each element of your design diagram with an expression denoting its failure behaviour.  The calculus then allows the whole system behaviour to be determined automatically.  I already had the calculus engine (written in Haskell) for some time now.  But although it generated SVG diagrams as output, for input it used a textual description of the diagrams, and so was quite fiddly to use - it would take forever to layout a diagram by manually adjusting coordinates and stuff, then running the batch tool to see the result, rinse and repeat.&lt;br /&gt;&lt;br /&gt;So, over the summer I came across Dazzle, a graphical tool for Bayesian analysis, written in Haskell using the wxWidgets toolkit.  There was a paper about it at the Haskell Workshop 2005 in Tallinn.  And I thought - hey, I need something just like that.  Luckily, Arjan who is one of the authors is a nice chap, and although he could not release the entire source code to me, he spent an afternoon stripping Dazzle down to just the diagram editor, with no analysis backend, and sent it to me, calling it &quot;Blobs&quot;.  Fantastic!  I didn&#39;t need to start a design from scratch, and didn&#39;t need to learn wxWidgets from scratch either.  Just start tweaking the code and see what happens!&lt;br /&gt;&lt;br /&gt;Well, today after only about a month&#39;s effort, I&#39;m finally happy that Blobs, with my analysis engine plugged in, gives me the same results as I had before, with the same pretty output diagrams.  But now it takes only minutes to draw a new diagram instead of hours.  Click a button and the analysis is performed instantly.  Very satisfying.  And really, Arjan&#39;s Blobs code in Haskell was a joy to work with - totally easy to understand and modify.&lt;br /&gt;&lt;br /&gt;Of course, this is only version 0.  I still have much more in the analysis engine (tracing, probability) than I ever worked out how to display even on SVG diagrams.  But these were difficult before in the batch-mode tool, mainly because of the tedious way needed to specify exactly what you wanted.  It should be a lot smoother in an interactive setting.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/112897152350480324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/112897152350480324' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112897152350480324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112897152350480324'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/10/completed-draft-0-of-interactive.html' title='Completed draft 0 of interactive diagramming tool.'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-112871256884970543</id><published>2005-10-07T19:57:00.000+01:00</published><updated>2005-10-07T20:16:08.860+01:00</updated><title type='text'>A new haskell compiler</title><content type='html'>Tom Shackell told me today about his &quot;short weekend&quot; project - he has completely reworked the backend of nhc98, and now has what amounts to the bulk of a new compiler he is provisionally calling &quot;yhc&quot; for York Haskell.  Neil thinks he should call it THC (Tom&#39;s...) instead. :-)&lt;br /&gt;&lt;br /&gt;The whole code generator and runtime system has been replaced.  It now generates a platform-independent bytecode stored directly in a binary format, instead of encoding it into platform-specific C arrays that needed further C compilation.  There are lots of great things about this. The generated code runs about 20% faster.  You can copy the bytecode from one architecture to another without needing to recompile.  The high-mem bug in nhc98&#39;s garbage collector is gone by default (new heap layout).  The bytecodes are dynamically linked, so it should be possible to hot-swap running code a la hs-plugins.  It works on 64-bit machines.  The runtime system can be compiled natively on Windows with VC++, as well as the original gcc on Unix way.&lt;br /&gt;&lt;br /&gt;All very cool.  Now we just need to replace the frontend as well - get a decent type inference engine etc.  Any volunteers?</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/112871256884970543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/112871256884970543' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112871256884970543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112871256884970543'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/10/new-haskell-compiler.html' title='A new haskell compiler'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17056150.post-112751071949807061</id><published>2005-09-23T22:23:00.000+01:00</published><updated>2005-09-23T22:25:19.503+01:00</updated><title type='text'>Everyone&#39;s doing it</title><content type='html'>Yes, blogs are the thing.  Actually, I only signed up to write one because I wanted to leave a short comment on someone else&#39;s article.</content><link rel='replies' type='application/atom+xml' href='http://nhc98.blogspot.com/feeds/112751071949807061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/17056150/112751071949807061' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112751071949807061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17056150/posts/default/112751071949807061'/><link rel='alternate' type='text/html' href='http://nhc98.blogspot.com/2005/09/everyones-doing-it.html' title='Everyone&#39;s doing it'/><author><name>malcolm</name><uri>http://www.blogger.com/profile/08863672971675777868</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://www-users.cs.york.ac.uk/~malcolm/img/malcolm.jpg'/></author><thr:total>0</thr:total></entry></feed>