<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for pesco</title>
    <link>http://www.advogato.org/person/pesco/</link>
    <description>Advogato blog for pesco</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Thu, 23 May 2013 13:50:20 GMT</pubDate>
    <item>
      <pubDate>Mon, 12 Feb 2007 23:25:13 GMT</pubDate>
      <title>12 Feb 2007</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=22</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=22</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p style="margin-top:0; margin-bottom:0;" /&gt;&lt;div style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt; Sometimes it can be so easy...
&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;...as &lt;tt style="font-size:0.9em;"&gt;chvt&lt;/tt&gt;(1). I'll just run an extra X-server without WM on a separate virtual terminal and switch to it remotely via SSH. It won't give of fancy transition animations &amp;agrave; la Beryl or Mac OS X, missing some of the futuristic-look-factor, but the functionality is what counts, right?
&lt;p &gt;On a side note, this whole plug-me-in-and-I'll-autojoin-the-larger-setup business reminds me of reading about "FlashMob computing" the other day. It sounded pretty much like they were still missing such "auto-integrate" (and auto-"exegrate") functionality...
&lt;p &gt;&lt;b style="padding-right:1ex;"&gt;PS.&lt;/b&gt; I apologize for a lack of links in my posts, but I've been sending them from my cell phone (yay &lt;tt style="font-size:0.9em;"&gt;advopost&lt;/tt&gt;) and can't look up the references, so bear with me for having to google out the links yourselves... ;)
&lt;p  /&gt;&lt;/div&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 12 Feb 2007 23:23:30 GMT</pubDate>
      <title>12 Feb 2007</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=21</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=21</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p &#xD;
style="margin-top:0; margin-bottom:0;" /&gt;&lt;div &#xD;
style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt; My laptop &#xD;
as a Plug&amp;#38;Play device&#xD;
&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;I'm &#xD;
the owner of two laptops, one slightly older and rather &#xD;
bulky 17" PowerBook, and a recent Panasonic T5. I now use &#xD;
the PB as my (stationary) main display via remote X while &#xD;
all work is done on the T5. To this end I've already got a &#xD;
script to automate the "attaching" of the T5, i.e. &#xD;
launching a window manager on the remote display and &#xD;
joining the two displays wrt. keyboard and mouse input &#xD;
with x2x.&lt;p &gt;I still have to manually kill the old WM on &#xD;
the PB, which I keep running when the T5 isn't connected &#xD;
(the PB still runs my MP3 player and an "emergency" web &#xD;
browser), and start up the network connection on the T5. &#xD;
The latter would be easy to automate but what I'm really &#xD;
looking for now is a way to also automatically have the WM &#xD;
on the PowerBook squirelled away in some "fast user &#xD;
switching"-like fashion so the regular environment could &#xD;
set itself up. Then on some other event, the whole thing &#xD;
should revert to the disconnected setup, automagically &#xD;
unsquirreling the "solo" environment again. I wonder how &#xD;
well the current state of the art in Linuxland will allow &#xD;
me to do that.&#xD;
&lt;p &gt;I've got my project for the weekend...&#xD;
&lt;p  /&gt;&lt;/div&gt;&#xD;
</description>
    </item>
    <item>
      <pubDate>Sun, 4 Feb 2007 15:30:01 GMT</pubDate>
      <title>4 Feb 2007</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=20</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=20</guid>
      <description>&lt;i&gt;Oops, a duplicate!&lt;/i&gt;</description>
    </item>
    <item>
      <pubDate>Sun, 4 Feb 2007 15:13:46 GMT</pubDate>
      <title>4 Feb 2007</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=19</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=19</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;&lt;div style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt; Oh my god, I&#xD;
finally found it...&#xD;
&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;...a&#xD;
decent MP3 player with stream support. Finally.&#xD;
&lt;p&gt;&lt;blockquote&gt;&lt;p style="margin-top:0;&#xD;
margin-bottom:0;"&gt;Hello, &lt;a href="http://moc.daper.net" &gt;MOC&lt;/a&gt;[1]! XMMS, go eff yourself.&#xD;
&lt;/blockquote&gt;&lt;p&gt;Of course I'm sorry for not using &lt;a href="http://www.cse.unsw.edu.au/~dons/hmp3.html" &gt;hmp3&lt;/a&gt;[2], but it doesn't do streams,&#xD;
appearently. At least not that I can tell from the website.&#xD;
Also missing Ogg&#xD;
support is a bit of a let-down.&#xD;
&lt;p&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[1]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Music On Console" &lt;a href="http://moc.daper.net" &gt;&lt;i&gt;http://moc.daper.net&lt;/i&gt;&lt;/a&gt;&#xD;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[2]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"hmp3 :: purely functional sound" &lt;a href="http://www.cse.unsw.edu.au/~dons/hmp3.html" &gt;&lt;i&gt;http://www.cse.unsw.edu.au/~dons/hmp3.html&lt;/i&gt;&lt;/a&gt;&#xD;
&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/div&gt;&#xD;
</description>
    </item>
    <item>
      <pubDate>Sat, 3 Feb 2007 01:32:12 GMT</pubDate>
      <title>3 Feb 2007</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=18</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=18</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p style="margin-top:0; margin-bottom:0;" /&gt;&lt;div style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt; Back from the dead, with a nonlinear parser
&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;Soo, everything went well different than planned. What was supposed to
be a holidy clean-up rewrite of a fun weekend project has turned into a
half-year side project running next to university.
&lt;p &gt;To recap, I initially set out to implement a Markdown[&lt;a href="http://daringfireball.net/projects/markdown/" title="&amp;#34;Markdown&amp;#34;" &gt;1&lt;/a&gt;] parser in
Haskell so I could post formatted text to my Advogato blog. An
email-to-Advogato gateway was quickly whipped up[&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=12" title="&amp;#34;Posting to Advogato via email&amp;#34;" &gt;2&lt;/a&gt;]. The first prototype
version of a Markdown parser was also finished within reasonable time[&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=16" title="&amp;#34;Structured text in Haskell redux&amp;#34;" &gt;3&lt;/a&gt;].
Unfortunately, the code was a mess, so I set out for the rewrite[&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=17" title="&amp;#34;Structural plain-text, next iteration&amp;#34;" &gt;4&lt;/a&gt;]. Much
progress was made but it kept screwing up in certain minor but annoying
cases and the code still looked convoluted. Basically, Parsec just
didn't want to bend in the right direction...
&lt;p &gt;So I replaced Parsec. The module is called
&lt;tt style="font-size:0.9em;"&gt;Text.ParserCombinators.Nonlinear&lt;/tt&gt;[&lt;a href="http://www.khjk.org/~sm/code/k-tex/Text/ParserCombinators/Nonlinear.lhs" title="&amp;#34;module Text.ParserCombinators.Nonlinear&amp;#34;" &gt;5&lt;/a&gt;] because it allows one to slurp in
parts of the document in one part of the parser and reparse them again
later. This allowed me to split up the document according to its
block-level structure and re-assemble, for instance, the text pieces of
quoted or indented lines (without the leading quote marks/indetation)
and run the corresponding parser over the thus extracted subdocument.
Such embedded parses can also work with a completely different token
type than the enclosing parser, a capability which also came in handy.
&lt;p &gt;I recently came across "Frisby"[&lt;a href="http://repetae.net/computer/frisby/index.html" title="&amp;#34;Text.Parsers.Frisby&amp;#34;" &gt;6&lt;/a&gt;], a Haskell implementation of PEG
grammars, which I had never heard of before. The description sounds
cool. I wonder if my Markdown variant could be represented by one? My
parser library is neither optimized for space nor speed, and PEGs sound
compelling in that regard...
&lt;p &gt;Anyway, the implementation based on my nonlinear parsers worked out
really nice wrt. the code structure and doesn't show any of the kinks
that plagued the Parsec version. Since I've deviated somewhat from
Markdown syntax in the places I didn't like, I've dubbed the package
&lt;tt style="font-size:0.9em;"&gt;k-tex&lt;/tt&gt;. I've still got to update the documentation but if anyone is
interested in looking at or even improving the code, you can find it at
&lt;a href="http://www.khjk.org/~sm/code/k-tex/" &gt;&lt;i&gt;http://www.khjk.org/~sm/code/k-tex/&lt;/i&gt;&lt;/a&gt;.
&lt;p &gt;Best regards,
Sven Moritz
&lt;p &gt;&lt;b style="padding-right:1ex;"&gt;PS.&lt;/b&gt; Yep, the Advogato gateway[&lt;a href="http://www.khjk.org/~sm/code/advopost/" title="&amp;#34;advopost&amp;#34;" &gt;7&lt;/a&gt;] already uses k-tex, and if this post
appears on my blog[&lt;a href="http://www.advogato.org/person/pesco/diary.html" title="&amp;#34;Advogato diary for pesco&amp;#34;" &gt;8&lt;/a&gt;], it's working. ;)
&lt;div style="margin-top:1.5em; margin-bottom:1em;"&gt;&lt;i&gt; References:&lt;/i&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[1]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Markdown" &lt;br /&gt;
&lt;a href="http://daringfireball.net/projects/markdown/" &gt;&lt;i&gt;http://daringfireball.net/projects/markdown/&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[2]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Posting to Advogato via email" &lt;br /&gt;
&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=12" &gt;&lt;i&gt;http://www.advogato.org/person/pesco/diary.html?start=12&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[3]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Structured text in Haskell redux" &lt;br /&gt;
&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=16" &gt;&lt;i&gt;http://www.advogato.org/person/pesco/diary.html?start=16&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[4]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Structural plain-text, next iteration" &lt;br /&gt;
&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=17" &gt;&lt;i&gt;http://www.advogato.org/person/pesco/diary.html?start=17&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[5]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"module Text.ParserCombinators.Nonlinear" &lt;br /&gt;
&lt;a href="http://www.khjk.org/~sm/code/k-tex/Text/ParserCombinators/Nonlinear.lhs" &gt;&lt;i&gt;http://www.khjk.org/~sm/code/k-tex/Text/ParserCombinators/Nonlinear.lhs&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[6]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Text.Parsers.Frisby" &lt;br /&gt;
&lt;a href="http://repetae.net/computer/frisby/index.html" &gt;&lt;i&gt;http://repetae.net/computer/frisby/index.html&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[7]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"advopost" &lt;br /&gt;
&lt;a href="http://www.khjk.org/~sm/code/advopost/" &gt;&lt;i&gt;http://www.khjk.org/~sm/code/advopost/&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[8]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt;"Advogato diary for pesco" &lt;br /&gt;
&lt;a href="http://www.advogato.org/person/pesco/diary.html" &gt;&lt;i&gt;http://www.advogato.org/person/pesco/diary.html&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;p  /&gt;&lt;/div&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 13 Jul 2006 19:13:23 GMT</pubDate>
      <title>13 Jul 2006</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=17</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=17</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p style="margin-top:0; margin-bottom:0;" /&gt;&lt;div style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt;Structural plain-text, next iteration&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;So, the first working version of my "structural plain-text" parser is just
working and I'm already dissatisfied with it. Well, the reasons are
simple:
&lt;p &gt;&lt;ol start="1" style="padding-left:3.5em;"&gt;&lt;li&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;It doesn't work correctly in all cases.&lt;li&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;The code is a mess, even though it &lt;em&gt;was&lt;/em&gt; already the third or so
iteration internally ("plan to throw...", you know).&lt;/ol&gt;So here we go for the next iteration. I hope I'll be able to make the
parser code substantially cleaner and more modular and implement a few
cool-to-have additional features along the way. But first I decided to
carefully write out a description of the intended grammar. I just finished
the first draft which is still missing details on the planned new
features. It's probably still full of inaccuracies because I've changed
some details from last time (in hopes of simplifying both the parser and
the syntax explanation) and I haven't implemented the actual parser, yet.
Still, if you're interested, have a &lt;a href="http://www.khjk.org/~sm/code/khjk-structured-text/Syntax.txt"  &gt;look&lt;/a&gt;[1].
&lt;p &gt;PS. Oh yeah, after all, I've included "strong emphasis" in this
version, because there &lt;em&gt;are&lt;/em&gt; uses for it, specifically in technical
documentation (which I intend to write). It carries a Fat Warning (TM) in
the docs, so I'm happy and people can do whatever they want. ;-)
&lt;p &gt;&lt;div style="text-align:left;"&gt;&lt;div style="float:left"&gt;[1]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt; &lt;a href="http://www.khjk.org/~sm/code/khjk-structured-text/Syntax.txt" &gt;&lt;i&gt;http://www.khjk.org/~sm/code/khjk-structured-text/Syntax.txt&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 5 Jul 2006 13:38:39 GMT</pubDate>
      <title>5 Jul 2006</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=16</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=16</guid>
      <description>&lt;div style="max-width:80ex; text-align:justify;"&gt;&lt;p style="margin-top:0; margin-bottom:0;" /&gt;&lt;div style="margin-top:2em; margin-bottom:1em;"&gt;&lt;b&gt;Structured text in Haskell redux, or "Posting to Advogato ASCII style"&lt;/b&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;A few weeks ago I posted my initial thoughts about how to represent
a structured text document in Haskell. As often with initial
thoughts, they were flawed. ;-) In particular, I wrote:
&lt;p &gt;&lt;blockquote style="border-left:solid medium gray; padding-left:1em; margin-left:0;"&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;I've tried to design the above types in such a way as to minimize the
possibility of forming non-sensical or ambiguous documents. That's
why there is such deep nesting of different types instead of just one
big algebraic data type with constructors for concatenation,
paragraph and section breaks, etc.&lt;/blockquote&gt;&lt;p &gt;Without going into too much detail, I stumbled over the problem in
the representation of block quotes: The corresponding constructor
expected a full &lt;tt style="font-size:0.9em;"&gt;Doc&lt;/tt&gt; and I couldn't break sufficiently small fragments
out of those for quoting. For example, had I wanted to quote one item
out of a numbered list, it would have gotten the number "1" again in
the quote, because it would have been the first item within that
document (fragment)...
&lt;p &gt;So, I thought, should I make one big data type for the whole document
after all? But still, I didn't want to include too much possibilities for
such senseless combinations as bulleted lists and blockquotes
within section headings. After some pondering I've decided on using
a two-level structure, with one data type representing documents
(or document fragments) at the block level (paragraphs, sections, etc.)
and a second one for in-line structures only. In particular, a document
is taken to be a list of "block-level tokens" ('Btok's):
&lt;pre style="font-size:0.9em; margin-left:2em; margin-right:2em;"&gt;type Doc = [Btok]
&lt;/pre&gt;Analogously, (logical) lines are represented by line-level tokens:
&lt;pre style="font-size:0.9em; margin-left:2em; margin-right:2em;"&gt;type Line = [Ltok]
&lt;/pre&gt;Apart from plain strings, these consist of things like emphasis,
code spans, etc.:
&lt;pre style="font-size:0.9em; margin-left:2em; margin-right:2em;"&gt;data Ltok =  St  String           -- character string
          |  Em  Line             -- emphasis
          |  Co  String           -- inline code
          ...
&lt;/pre&gt;Note that under their intended interpretation, these constructors form
&lt;em&gt;homomorphisms&lt;/em&gt; into the monoid of &lt;tt style="font-size:0.9em;"&gt;Ltok&lt;/tt&gt;-lists (wrapping their
result in a single-element list): e.g. &lt;tt style="font-size:0.9em;"&gt;[St a] ++ [St b]&lt;/tt&gt; is expected
to be equal to &lt;tt style="font-size:0.9em;"&gt;[St (a++b)]&lt;/tt&gt;, &lt;tt style="font-size:0.9em;"&gt;[Em a] ++ [Em b] == [Em (a++b)]&lt;/tt&gt;, etc.
This enables one to split a line in two at an arbitrary point without
"losing any information". :-)
&lt;p &gt;I noticed that if something like the above could hold for the
block-level &lt;tt style="font-size:0.9em;"&gt;Doc&lt;/tt&gt; type as well, my block quote problem would be
solved pretty elegantly. And indeed, I found the following
representation:
&lt;pre style="font-size:0.9em; margin-left:2em; margin-right:2em;"&gt;data Btok =  TEXT  [Line]    -- text block (logical lines)
 
          |  PARA  Line      -- new paragraph (w. opt. title)
          |  SECT  Int Line  -- new section (of given level)
 
          |  QUOT  Doc       -- blockquote
          |  BULL  [Doc]     -- bulleted list
          ...
&lt;/pre&gt;Notice that the &lt;tt style="font-size:0.9em;"&gt;PARA&lt;/tt&gt; and &lt;tt style="font-size:0.9em;"&gt;SECT&lt;/tt&gt; constructors do not wrap the
corresponding paragraph or section. Their meaning is analogous to
that of a new-line character in plain-text: they start a new structure
which spans everything up to the next break. This is exactly what makes
&lt;tt style="font-size:0.9em;"&gt;QUOT&lt;/tt&gt; work: We can break the document apart in the middle of a
section or paragraph and rightfully consider the resulting parts
fragments in the common sense that they can be glued back together to
form the original. Or to put it differently, a quoted fragment
carries all of its "own" structural information (where the meaning of
"own" also results from the data type's structure).
&lt;div style="margin-top:1.5em; margin-bottom:1em;"&gt;&lt;i&gt;"Wait, there's more fun to be had!"
&lt;/i&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;Remember that the whole point of my foray into structured documents
originated in my little project of posting to my Advogato diary via
email. So, say I had a document to be posted in memory as a value
of type &lt;tt style="font-size:0.9em;"&gt;Doc&lt;/tt&gt; as above. I'd want to convert it to HTML (or Advogato's
subset thereof). While the representation of section breaks as
stand-alone &lt;tt style="font-size:0.9em;"&gt;SECT&lt;/tt&gt;s within a stream of block tokens closely fits with
the &lt;tt style="font-size:0.9em;"&gt;&amp;#60;h1-6&amp;#62;&lt;/tt&gt; tags to appear in the HTML, paragraphs are supposed to
be &lt;em&gt;wrapped&lt;/em&gt; in &lt;tt style="font-size:0.9em;"&gt;&amp;#60;p&amp;#62;&lt;/tt&gt; tags. One obvious (but annoying) solution to
this discrepancy would be to build a second data type, probably a
little more like my original idea again, and convert to HTML via the
detour of this intermediate type.
&lt;p &gt;Luckily I remembered that &lt;a href="http://okmij.org/" title="Oleg Kiselyov, Haskell (and Scheme (and probably more)) guru. See ." &gt;Oleg&lt;/a&gt;[1] wrote something about &lt;a href="http://okmij.org/ftp/Computation/Continuations.html#enumerator-stream" title="Oleg Kiselyov: \" Towards the best collection traversal interface \"."&gt;folds being
superior to cursors&lt;/a&gt;[2] as interfaces to data collections, so I
implemented a function of the following humiliating type signature.
;)
&lt;pre style="font-size:0.9em; margin-left:2em; margin-right:2em;"&gt;-- Fold over a Doc's block-level structure.
folddoctree
  ::  (Biblio -&amp;#62; Line -&amp;#62; line)     -- logical line
 
      -&amp;#62; ([line] -&amp;#62; tok)           -- text block
      -&amp;#62; (String -&amp;#62; tok)           -- code block
      -&amp;#62; (doc -&amp;#62; tok)              -- blockquote
      -&amp;#62; ([doc] -&amp;#62; tok)            -- bulleted list
      -&amp;#62; (Int -&amp;#62; [doc] -&amp;#62; tok)     -- numbered list
      -&amp;#62; ([(String,line)] -&amp;#62; tok)  -- bibliography
 
      -&amp;#62; (  line                   -- para. title
            -&amp;#62; [tok]               -- para. content
            -&amp;#62; para  )             -- paragraph
 
      -&amp;#62; (  Int                    -- sect. level
            -&amp;#62; line                -- sect. title
            -&amp;#62; doc                 -- sect. content
            -&amp;#62; sect  )             -- section
 
      -&amp;#62; (  [para]                 -- initial paragraphs
            -&amp;#62; [sect]              -- following sections
            -&amp;#62; doc  )              -- document
 
      -&amp;#62; Doc -&amp;#62; doc
&lt;/pre&gt;As you can see, it takes ten functions as parameters, each telling it
what to do with a certain part of the document, which it then
transforms accordingly. Given this function, an HTML export for
&lt;tt style="font-size:0.9em;"&gt;Doc&lt;/tt&gt;s is straight-forward to define.
&lt;p &gt;&lt;b style="padding-right:0.5em;"&gt;NB.&lt;/b&gt; Notice how the different type variables are threaded through
the type signature. It feels almost like LISP, in the sense that the
functions can return any type they want, as long as everything fits.
But unlike in a dynamically-typed language, the typechecker will tell
you up-front if you make a mistake. :-P
&lt;div style="margin-top:1.5em; margin-bottom:1em;"&gt;&lt;i&gt;"Show me the code!"
&lt;/i&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;Ah right, most important! The full definitions of the &lt;tt style="font-size:0.9em;"&gt;Doc&lt;/tt&gt; type, the
&lt;tt style="font-size:0.9em;"&gt;folddoctree&lt;/tt&gt; function, and some further utilities can be seen at the
following address:
&lt;p &gt;  &lt;a href="http://www.khjk.org/~sm/code/advopost/Doc.lhs" &gt;&lt;i&gt;http://www.khjk.org/~sm/code/advopost/Doc.lhs&lt;/i&gt;&lt;/a&gt;
&lt;p &gt;Enjoy! :-)
&lt;div style="margin-top:1.5em; margin-bottom:1em;"&gt;&lt;i&gt; References:
&lt;/i&gt;&lt;/div&gt;&lt;p style="margin-top:0; margin-bottom:0;"&gt;&lt;div style="float:left"&gt;[1]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt; Oleg Kiselyov, Haskell (and Scheme (and probably more)) guru.
     See &lt;a href="http://okmij.org/" &gt;&lt;i&gt;http://okmij.org/&lt;/i&gt;&lt;/a&gt;.
&lt;/div&gt;&lt;div style="float:left"&gt;[2]&lt;/div&gt;&lt;div style="margin-left:4ex"&gt; Oleg Kiselyov: "Towards the best collection traversal interface".
     &lt;a href="http://okmij.org/ftp/Computation/Continuations.html#enumerator-stream" &gt;&lt;i&gt;http://okmij.org/ftp/Computation/Continuations.html#enumerator-stream&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 11 Jun 2006 21:44:44 GMT</pubDate>
      <title>11 Jun 2006</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=15</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=15</guid>
      <description>&lt;b&gt;Fun with email -- or how I spent my day&lt;/b&gt;
 
&lt;p&gt;
I'd like to share the results of my latest "freshmeat" spree.
For context, I keep all my email on a University server, so I can access
it from anywhere (No, &lt;i&gt;there are no webmailers&lt;/i&gt;!). I have access through
IMAP which I used with Thunderbird, until yesterday -- when I finally got
fed up with it. Thunderbird regularly mixes up its idea of which mail folders
there are on the IMAP server, and where. So there I was, looking for a new MUA.
Lot's of dissatisfaction ensued. Until I found two wonderful programs:
 
&lt;p&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.quux.org/devel/offlineimap/" &gt;
OfflineIMAP&lt;/a&gt;
    &lt;li&gt;&lt;a href="http://mutt-ng.berlios.de/" &gt;
Mutt-NG&lt;/a&gt;
&lt;/ol&gt;
 
&lt;p&gt;
The first does something very simple (but in a smart way): It synchronizes IMAP
mailboxes with a local repository. Both ways. So I set it up with all my
IMAP settings (through a &lt;i&gt;nice&lt;/i&gt;, and "unuserfriendly" config file -- sic!)
and let it sync every five minutes. New mails get pulled into local Maildir
folders where any old MUA can conveniently handle them. And whatever changes
I make to them are propagated back to the server. And no, it doesn't lose any
mails; so the author assures. The author, btw., turns out to be a fellow
Haskell programmer -- &lt;a href="http://changelog.complete.org/" &gt;
John Goerzen&lt;/a&gt;, thank you: &lt;i&gt;You just made my day&lt;/i&gt;!
 
&lt;p&gt;
Thanks to OfflineIMAP I can finally use my old-time favourite MUA again:
Mutt. But wait, as I discovered, there is even Mutt-NG now, which finally
adds the one thing I had been missing all along: A sidebar that shows an
overview of (new/old/etc.) messages in my incoming mail folders! Oh, and for
extra pleasure, it also speaks SMTP, so I don't even have to set up a local
delivery agent.
 
&lt;p&gt;
And here's some more general Mutt praise: With just a few pretty simple
config file (sic!) settings, mutt pretty much takes care of moving read mails
away into yearly archive folders all by itself:
 
&lt;p&gt;
&lt;blockquote&gt;&lt;pre&gt;
save-hook ~A =sa-spam
&lt;/pre&gt;&lt;/blockquote&gt;
 
&lt;p&gt;
This means that pressing 's' to move a message to another folder presents
sa-spam as default, which happens to be the folder my spamassasin learns
from.
 
&lt;p&gt;
&lt;blockquote&gt;&lt;pre&gt;
set record="=Archive/`date +%Y`/Sent"
&lt;/pre&gt;&lt;/blockquote&gt;
 
&lt;p&gt;
This is where mutt saves Fcc's, i.e. copies of sent messages. Notice the
automatic year selection.
 
&lt;p&gt;
&lt;blockquote&gt;&lt;pre&gt;
set mbox="=Archive/`date +%Y`/Inbox"
mbox-hook =Somelist   =Archive/`date +%Y`/Somelist
mbox-hook =Otherlist  =Archive/`date +%Y`/Otherlist
&lt;/pre&gt;&lt;/blockquote&gt;
 
&lt;p&gt;
Finally, these are the real fun: Remember how default Mutt setups usually
ask on quit whether they should save read messages to "mbox" in your homedir?
A completely stupid question, nobody wants that. But with the above, this
suddenly changes to something sensible: The correct archive folder for the
current year, sorting different input folders into a corresponding archive
subfolder. Wonderful.
 
&lt;p&gt;
Maybe you cannot really appreciate how good this is. But that's usually the
case with improved usability, you don't notice until afterwards how much
better things feel with just that little tweak. Compare my 
&lt;a href="http://www.advogato.org/person/pesco/diary.html?start=8" &gt;previous post
about bitlbee&lt;/a&gt;. Life just started being &lt;i&gt;fun&lt;/i&gt; again! Time to throw out all
those &lt;a href="http://www.x-tra-x.de/bilder/artikel/08479-g.jpg" &gt;black clothes&lt;/a&gt; and start listening to &lt;a href="http://www.vengahome.de/" &gt;eurodance&lt;/a&gt;.
 
&lt;p&gt;
Enjoy.
 
&lt;p&gt;
&lt;b&gt;PS.&lt;/b&gt; Friendly apologies for praising config files go to &lt;a href="http://www.advogato.org/person/lkcl/" &gt;lkcl&lt;/a&gt;
who &lt;a href="http://www.advogato.org/person/lkcl/diary.html?start=285" &gt;recently bitched&lt;/a&gt; about "this crap obscure text file editing shit". ;-P</description>
    </item>
    <item>
      <pubDate>Sat, 10 Jun 2006 10:57:18 GMT</pubDate>
      <title>10 Jun 2006</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=14</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=14</guid>
      <description>&lt;b&gt;"About the Swedish analysis of Nazi Germany's crypto teleprinters"&lt;/b&gt;
 
&lt;p&gt;
I've just returned from a two-semester exchange at the &lt;a href="http://www.cuni.cz" title="Univerzita Karlova v Praze" &gt;Charles
University&lt;/a&gt;[1] of Prague. There I had the chance to take a course about
classical cryptography, for which I wrote an essay that might be
interesting to others:

 
&lt;p&gt;
Everybody knows about the &lt;a href="http://en.wikipedia.org/wiki/Enigma_machine" title="Enigma machine" &gt;Enigma machine&lt;/a&gt;[2]. It was a cryptographic
device developed by the Germans, used extensively by Hitler's troops,
and famously broken by the allies at Bletchley Park. It was an "offline"
device in that the plaintext was keyed in letter by letter, indicating
the corresponding ciphertext character with each keystroke. Now, what
many are not aware of is that the Germans also used a series of online
crypto devices during WWII. One of these was the &lt;a href="http://en.wikipedia.org/wiki/Siemens_and_Halske_T52" title="Siemens and Halske T52" &gt;Siemens T52&lt;/a&gt;[3],
a.k.a. the "Geheimschreiber". This machine was an actual teleprinter
with built-in automatic encryption and decryption, i.e. it encrypted and
transmitted the characters as they were typed (or fed via punched tape),
and vice-versa. It's cryptographic algorithm is considered significantly
more sophisticated than that of the Enigma.

 
&lt;p&gt;
When Germany leased several telegraph lines from Sweden they were
immediately tapped but the T52 was soon employed on them. &lt;a href="http://www.khjk.org/~sm/distfiles/sm-2006-gschreiber.pdf" title="About the Swedish analysis of Nazi Germany's crypto teleprinters" &gt;My essay&lt;/a&gt;[4]
describes how the Swedish cryptanalyst Arne Beurling broke the
encryption without ever having seen one of the machines. It's mainly a
condensed form of the description from "Codebreakers"[5], with less
history and more mathematics.

 
&lt;p&gt;Enjoy.
 
&lt;p&gt;
&lt;i&gt;References:&lt;/i&gt;&lt;br&gt;
 
&lt;div style="padding-left: 1ex"&gt;
&lt;div style="float: left"&gt;[1]:&lt;/div&gt;
&lt;div style="margin-left: 5ex"&gt;
  "Univerzita Karlova v Praze"&lt;br&gt;
  &lt;a href="http://www.cuni.cz" &gt;http://www.cuni.cz/&lt;/a&gt;
&lt;/div&gt; 
 
&lt;div style="float: left"&gt;[2]:&lt;/div&gt;
&lt;div style="margin-left: 5ex"&gt;
  Wikipedia: "Enigma machine"&lt;br&gt;
  &lt;a href="http://en.wikipedia.org/wiki/Enigma_machine" &gt;http://en.wikipedia.org/wiki/Enigma_machine&lt;/a&gt;
&lt;/div&gt;
 
&lt;div style="float: left"&gt;[3]:&lt;/div&gt;
&lt;div style="margin-left: 5ex"&gt;
  Wikipedia: "Siemens and Halske T52"&lt;br&gt;
  &lt;a href="http://en.wikipedia.org/wiki/Siemens_and_Halske_T52" &gt;http://en.wikipedia.org/wiki/Siemens_and_Halske_T52&lt;/a&gt;
&lt;/div&gt;
 
&lt;div style="float: left"&gt;[4]:&lt;/div&gt;
&lt;div style="margin-left: 5ex"&gt;
  Sven Moritz Hallberg: "About the Swedishh analysis of Nazi Germany's crypto teleprinters" (2006)
  &lt;a href="http://www.khjk.org/~sm/distfiles/sm-2006-gschreiber.pdf" &gt;http://www.khjk.org/~sm/distfiles/sm-2006-gschreiber.pdf&lt;/a&gt;
&lt;/div&gt;
 
&lt;div style="float: left"&gt;[5]:&lt;/div&gt;
&lt;div style="margin-left: 5ex"&gt;
  Bengt Beckman: "Codebreakers: Arne Beurling and the Swedish Crypto Program during World War II", Oxford University Press (2003)
&lt;/div&gt;
&lt;/div&gt;
 
 
&lt;p&gt;
&lt;b&gt;Update: Typesetting a reference list in Advogato&lt;/b&gt;

 
&lt;p&gt;
For those of you who, like me, are not completely fluent
in CSS (and maybe a little stuck with HTML wisdom of the 90's), here's how you produce hanging indents as in the reference list above:
&lt;ol&gt;
 &lt;li&gt;
 Somehow determine the width of your left column.
 For the reference list, I took the maximum number of
 characters in it plus one, times the width of the
 'x' character (ex): "[n]:" are four
 characters, so I use 5ex.
 
 &lt;li&gt;
 Put the left column text into a &amp;lt;div&amp;gt; and give
 it the attribute 'style="float: left"', so that
 the following text will flow down to the right of it.
 
 &lt;li&gt;
 Put the right column text into another &amp;lt;div&amp;gt;
 and give it the attribute 'style="margin-left: 5ex"'
 (replacing 5ex with whatever left-column width you want).
 This results in the hanging indent.
 
&lt;/ol&gt;
 
For reference, here's the code to the first reference
entry above:
 
&lt;blockquote&gt;&lt;pre&gt;
&amp;lt;div style="float: left"&amp;gt;[1]:&amp;lt;/div&amp;gt;
&amp;lt;div style="margin-left: 5ex"&amp;gt;
  "Univerzita Karlova v Praze"&amp;lt;br&amp;gt;
  &amp;lt;a href="http://www.cuni.cz"&amp;gt;http://www.cuni.cz/&amp;lt;/a&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;/blockquote&gt;
 
&lt;p&gt;
For a reference list, it also looks good to indent
the whole thing a little by putting it
in another &amp;lt;div style="padding: 1ex"&amp;gt;.

 
&lt;p&gt;Enjoy
</description>
    </item>
    <item>
      <pubDate>Thu, 1 Jun 2006 10:12:58 GMT</pubDate>
      <title>1 Jun 2006</title>
      <link>http://www.advogato.org/person/pesco/diary.html?start=13</link>
      <guid>http://www.advogato.org/person/pesco/diary.html?start=13</guid>
      <description>&lt;b&gt;Representing marked-up text in Haskell&lt;/b&gt;

&lt;p&gt; I wrote previously about my plan to use Markdown as the input format for
advopost. I decided against re-using the existing Markdown-to-HTML
converter, because I would have to strip the resulting output down to
the Advogato subset of HTML in postprocessing; feels too clutchy. So I'm
going to implement a parser for (a variant of) Markdown that reads the
input into a structured Haskell data type 'Doc'. Here is my current
design for that type:

&lt;p&gt; &lt;pre&gt;
   module Doc where
&lt;/pre&gt;
&lt;pre&gt;
   data Doc     =  Doc         String      -- title
                               [Para]      -- body
                               [Doc]       -- subsections 
&lt;/pre&gt;
&lt;pre&gt;
   data Para    =  Paragraph   String      -- paragraph title
                               [Block]     -- paragraph body
&lt;/pre&gt;
&lt;pre&gt;
   data Block   =  Blockquote  Doc
                |  Bulleted    [[Para]]    -- unordered list
                |  Numbered    [[Para]]    -- numbered list
                |  Codeblock   [[Inline]]  -- list of lines, ignore Codespans
                |  Line        [Inline]
&lt;/pre&gt;
&lt;pre&gt;
   data Inline  =  Str         String      -- ignore linebreaks
                |  Codespan    [Inline]
                |  Emph        [Inline]
                |  Link        [Inline]    -- link text
                               String      -- link target
                               String      -- link title
                |  Image       [Inline]    -- fallback alternative for this image
                               String      -- image location
                               String      -- image title
&lt;/pre&gt;

&lt;p&gt; I want both the input format and the Haskell data structure to be
independent of the output format being HTML. Therefore I'm not going to
support inline-HTML in the input. I also want structural markup (as
opposed to presentational), so I left out horizontal rules and forced
linebreaks. Lastly, I've never heard of using a "strong emphasis" (as
opposed to normal emphasis) in typesetting, so I dropped that as well.

&lt;p&gt; I've tried to design the above types in such a way as to minimize the
possibility of forming non-sensical or ambiguous documents. That's why
there is such deep nesting of different types instead of just one big
algebraic data type with constructors for concatenation, paragraph and
section breaks, etc.. Comments welcome.

&lt;p&gt; I hope that the 'Doc' type will be useful in further coding. For
example, it would be really cool to have a fancy combinator library for
'Doc's along with a pretty-printer to turn them back into plaintext:
Then we could use them for general pretty output from Haskell programs.
While there are several existing pretty-printing libraries, to my
knowledge none of them use structural markup and they are all targeted
at console output only.</description>
    </item>
  </channel>
</rss>
