<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0">
 <channel>
  <title>David Christiansen: David Christiansen</title>
  <description>David Christiansen: David Christiansen</description>
  <link>http://www.davidchristiansen.dk/blog/index.html</link>
  <lastBuildDate>Wed, 03 Dec 2014 08:00:00 UT</lastBuildDate>
  <pubDate>Wed, 03 Dec 2014 08:00:00 UT</pubDate>
  <ttl>1800</ttl>
  <item>
   <title>Filling out source locations in Idris</title>
   <link>http://www.davidchristiansen.dk/2014/12/03/filling-out-source-locations-in-idris</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-12-03-filling-out-source-locations-in-idris</guid>
   <pubDate>Wed, 03 Dec 2014 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;The mainline branch of Idris now has support for source location reflection. This means that Idris code can be informed about which line and column of which file it occurs on. In this post, I&amp;#8217;ll walk you through how this can be used for implementing programmer tools, such as a facility similar to Haskell&amp;#8217;s &lt;span class="stt"&gt;error&lt;/span&gt; function. Then, I&amp;#8217;ll briefly discuss how the feature is implemented and the implications for referential transparency and claims of purity.&lt;/p&gt;

&lt;p&gt;Note that I&amp;#8217;m not claiming any major innovation here &amp;#8211; this blog post exists only to explain a feature that I took from &lt;a href="http://lampwww.epfl.ch/~amin/pub/hosc2013.pdf"&gt;scala-virtualized&lt;/a&gt; and implemented in Idris.&lt;/p&gt;
&lt;!--more--&gt;

&lt;h1&gt;&lt;a name="(part._.Terminating_with_an_error)"&gt;&lt;/a&gt;Terminating with an error&lt;/h1&gt;

&lt;p&gt;The &lt;span class="stt"&gt;error&lt;/span&gt; function stops execution immediately, printing a user-supplied message. Because it will never return, it should inhabit every type, but it should most assuredly &lt;span style="font-style: italic"&gt;not&lt;/span&gt; pass the totality checker.&lt;/p&gt;

&lt;p&gt;It is straightforward to implement &lt;span class="stt"&gt;error&lt;/span&gt; using Idris&amp;#8217;s unsafe features. The C FFI can be used to call &lt;span class="stt"&gt;exit&lt;/span&gt;, terminating the program, and &lt;span class="stt"&gt;unsafePerformIO&lt;/span&gt; allows us to call arbitrary C functions in a pure context. The built-in primitive &lt;span class="stt"&gt;believe_me&lt;/span&gt; enables us to subvert the type checker. Combining these ingredients yields:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;||| Terminate the program after printing a user-specified error message.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;|||&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;||| @ message The error to print&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;partial&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;error : (message : String) -&amp;gt; a&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;error message =&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;believe_me . unsafePerformIO $&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;do putStrLn message&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;exit 1&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;If this function is ever called, it means that something has gone wrong, and we have a bug in our program. However, the error itself may not be particularly helpful: there may be insufficient clues to determine why it occurred. Knowing where it occurred in the source code can make it much easier to debug the problem. Let&amp;#8217;s extend &lt;span class="stt"&gt;error&lt;/span&gt; to display its call site along with the message.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Source_.Locations_for_.Dynamic_.Errors)"&gt;&lt;/a&gt;Source Locations for Dynamic Errors&lt;/h1&gt;

&lt;p&gt;Broadly speaking, Idris functions accept two kinds of arguments: &lt;span style="font-style: italic"&gt;explicit&lt;/span&gt; arguments, which the user directly provides, and &lt;span style="font-style: italic"&gt;implicit&lt;/span&gt; arguments, which the compiler is expected to work out for itself in most situations. An explicit argument can be provided implicitly by writing and underscore in its position, and an implicit argument can be provided explicitly by writing it in curly braces.&lt;/p&gt;

&lt;p&gt;Implicit arguments are normally solved by &lt;span style="font-style: italic"&gt;unification&lt;/span&gt;. In other words, something else in the program will typically cause there to be precisely one possible value that would still type check, so the compiler is able to fill it out. When defining a function, you can specify an alternative way to fill out the implicit argument, such as by providing a default value or invoking the proof search system. Additionally, the default value need not be literal Idris code: it can also be a tactic script to be executed during &lt;span style="font-style: italic"&gt;elaboration&lt;/span&gt;, which is what we call the process of translating the high level Idris code that users write into the highly tedious, fully explicit core language that the compiler then proceeds to optimize and send off to the individual backends. Typical tactics include things like &lt;span class="stt"&gt;refine&lt;/span&gt;, which applies a name to the goal, generating subgoals as necessary for its arguments, and &lt;span class="stt"&gt;try&lt;/span&gt;, which attempts one tactic and falls back to another if the first fails.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="SIntrapara"&gt;As of a few days ago, Idris supports a new tactic called &lt;span class="stt"&gt;sourceLocation&lt;/span&gt; that fills out the argument using the source location at which it was invoked. This tactic can be used to improve the messages from &lt;span class="stt"&gt;error&lt;/span&gt;. Source locations are provided using the type &lt;span class="stt"&gt;Language.Reflection.SourceLocation&lt;/span&gt;, which is defined as follows:
&lt;/div&gt;

&lt;div class="SIntrapara"&gt;
 &lt;table cellpadding="0" cellspacing="0"&gt;
  &lt;tbody&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;data SourceLocation : Type where&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;FileLoc : String -&amp;gt; (Int, Int) -&amp;gt; (Int, Int) -&amp;gt; SourceLocation&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first argument to the constructor is the source file name, and the second and third are the line and column at the beginning and end of the relevant expression. Because not all of the parser has been updated to save source spans, the second and third arguments are often identical for now, but this will eventually be fixed.&lt;/p&gt;

&lt;p&gt;To improve the messages provided by &lt;span class="stt"&gt;error&lt;/span&gt;, we need to arrange for the &lt;span class="stt"&gt;sourceLocation&lt;/span&gt; tactic to be used to fill out an implicit source context argument. Then, we can destructure this implicit argument using ordinary pattern matching to recover the filename, line number, and column number to report. The updated &lt;span class="stt"&gt;error&lt;/span&gt; function (which is in the Idris library in the &lt;span class="stt"&gt;Debug.Error&lt;/span&gt; package) is:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;||| Terminate the program after printing a user-specified error message.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;|||&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;||| @ loc&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;The source location to display for the error&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;||| @ message The error to print&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;partial&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;error : {default tactics {sourceLocation} loc : SourceLocation} -&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(message : String) -&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;a&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;error {loc = FileLoc filename (line, col) _} message =&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;believe_me . unsafePerformIO $&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;do let place = filename ++ " line " ++ show line ++ " column " ++ show col&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;let message' = place ++ ": " ++ message&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;putStrLn message'&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;exit 1&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The same basic technique can also be used to report source locations for errors in deeply embedded langauges that aren&amp;#8217;t easily encoded in the type system. Note that higher-level features, such as an assertions system built on top of &lt;span class="stt"&gt;error&lt;/span&gt;, can provide &lt;span class="stt"&gt;loc&lt;/span&gt; explicitly, enabling them to override the displayed source code location with their own. This straightforwardly allows a fine-grained control over the level at which errors should be displayed.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Implementation)"&gt;&lt;/a&gt;Implementation&lt;/h1&gt;

&lt;p&gt;Idris&amp;#8217;s expression elaborator is a recursive traversal of the expression. Elaboration occurs within a monad that resembles a tactic-based interactive theorem prover, with a present goal and list of assumptions, a stack of remaining goals to be solved, and tactics that manipulate this state. Smaller tatics can be composed to create larger tactics. For details, check out &lt;a href="http://eb.host.cs.st-andrews.ac.uk/drafts/impldtp.pdf"&gt;Edwin&amp;#8217;s JFP paper from last year&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The high-level Idris AST already contains source code information, which is used to report static error messages such as unification errors. To implement &lt;span class="stt"&gt;sourceLocation&lt;/span&gt;, the already-existing source locations are simply used to generate Idris-level source locations. Because not every term resulting from the parser contains a source location, the closest containing location is passed recursively in the elaborator.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Purity)"&gt;&lt;/a&gt;Purity&lt;/h1&gt;

&lt;p&gt;Does this change mean that Idris is no longer a pure language? After all, the following function will return a different value depending on where it is called:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;getLocation : {default tactics {sourceLocation} loc : SourceLocation} -&amp;gt; SourceLocation&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;getLocation {loc} = loc&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Even mere changes to whitespace could cause a program that uses &lt;span class="stt"&gt;getLoc&lt;/span&gt; to compute a radically different value!&lt;/p&gt;

&lt;p&gt;However, this does not affect the purity of the uderlying core language. From the perspective of the core, when you move a call to &lt;span class="stt"&gt;getLoc&lt;/span&gt; to a new location, the term itself changes, and the constant value of &lt;span class="stt"&gt;loc&lt;/span&gt; is simply changed. While this feature could most assuredly be abused, it is surely no worse than type class resolution or proof search when it comes to purity.&lt;/p&gt;

&lt;p&gt;If you find a creative use for the &lt;span class="stt"&gt;sourceLocation&lt;/span&gt; tactic or if you use it in a serious manner, please let me know! I&amp;#8217;d love to hear how it works for real-world users.&lt;/p&gt;</description></item>
  <item>
   <title>A Pretty-Printer That Says What it Means</title>
   <link>http://www.davidchristiansen.dk/2014/09/06/a-pretty-printer-that-says-what-it-means</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-09-06-a-pretty-printer-that-says-what-it-means</guid>
   <pubDate>Sat, 06 Sep 2014 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;Idris supports &lt;span style="font-style: italic"&gt;semantic&lt;/span&gt; highlighting of compiler output. In this post, I&amp;#8217;ll sketch what the feature brings users, why it&amp;#8217;s interesting, what inspired it, and how it&amp;#8217;s implemented in the Idris compiler. Rather than spending a bunch of time describing a series of screenshots, here&amp;#8217;s &lt;a href="http://www.youtube.com/watch?v=B5PRPzWZJ60"&gt;a quick video of it in action&lt;/a&gt;, inside of &lt;a href="https://github.com/idris-hackers/idris-mode"&gt;idris-mode&lt;/a&gt; for Emacs:&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;
 &lt;iframe class="youtube-player" frameborder="0" height="390" src="//www.youtube-nocookie.com/embed/B5PRPzWZJ60" title="YouTube video player" type="text/html" width="480"&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;Note that all the interesting features there are implemented in the Idris compiler (specifically, the pretty-printer), and that Emacs does very little work to use these features. They are available for any editor, and partially at the command line REPL, in a manner that can be incrementally implemented to get more and more features.&lt;/p&gt;

&lt;p&gt;I showed Simon Peyton Jones a quick demo at the Haskell Implementors&amp;#8217; Workshop in Gothenburg today, and he encouraged me to write it up, thinking that there might be more general interest. So here we go!&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Context)"&gt;&lt;/a&gt;Context&lt;/h1&gt;

&lt;p&gt;The Idris compiler and REPL have two output modes: one intended for direct human interaction in a terminal, and one intended for integration into external tools. When in console mode, Idris emits ANSI codes in its output stream that place semantically relevant font information into the interpreter output. However, we&amp;#8217;re limited by what terminals support. When working with more expressive output contexts, we can present much more than just fonts.&lt;/p&gt;

&lt;p&gt;Output intended for other programs, when Idris is running in IDE mode, consists of S-expressions that represent the semantics of the output. Sometimes, the entire sense of the message can be a machine readable message, but other times annotated strings are sent. Examples of the first include a notification that a file was successfully type checked and a signal indicating that the user has completed a tactic proof, and examples of the second include error messages and REPL output. In this post, I&amp;#8217;ll mostly focus on how annotated strings are generated, as it&amp;#8217;s the most fun part. I&amp;#8217;m focusing on the underlying ideas here, so I&amp;#8217;m glossing over some details and type signatures may not match the real ones in the Idris code base.&lt;/p&gt;

&lt;p&gt;Having colors in the output from the Idris interpreter was originally inspired by a demonstration of Julia at OPLSS 2013, by &lt;a href="http://blog.leahhanson.us/"&gt;Leah Hanson&lt;/a&gt;. I was really impressed by how the colored output from the REPL was helpful in understanding the results and distinguishing between program output and expression values. I was also feeling envious of Agda&amp;#8217;s nice semantic coloring in Emacs buffers.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.The_.Pretty-.Printer)"&gt;&lt;/a&gt;The Pretty-Printer&lt;/h1&gt;

&lt;p&gt;All output from the Idris compiler is generated by the Idris pretty-printer. In this pretty-printer, we need to do two things: (1) generate strings from compiler data structures, and (2) maintain the link between regions of these strings and semantically interesting information about them. For example, the compiler needs to know that the &amp;#8220;Nat&amp;#8221; in &amp;#8220;Z : Nat&amp;#8221; is a type constructor and that &amp;#8220;Z&amp;#8221; is a data constructor, and furthermore that both really occur in the namespace &amp;#8220;Prelude.Nat&amp;#8221;, but are being displayed in a truncated form. That way, the full disambiguated name can be used to do things like looking up documentation.&lt;/p&gt;

&lt;p&gt;It is not possible, however, to maintain the link between regions of text and semantic annotations during pretty-printing, because the whole reason we have a pretty-printer is to free us from the burden of performing specific text formatting. The pretty-printing library combinators generate an abstract type &lt;span class="stt"&gt;Doc&lt;/span&gt;, which can later be rendered to specific output contexts, such as terminals of different widths.&lt;/p&gt;

&lt;p&gt;The approach taken in Idris to bridge this gap is to replace the type &lt;span class="stt"&gt;Doc&lt;/span&gt; with a type constructor &lt;span class="stt"&gt;Doc a&lt;/span&gt;, where the type &lt;span class="stt"&gt;a&lt;/span&gt; represents the type of the semantic annotations in the document. Then, a single additional combinator &lt;span class="stt"&gt;annotate :: a -&amp;gt; Doc a -&amp;gt; Doc a&lt;/span&gt; can be used to attach elements of the semantic annotation type to the document.&lt;/p&gt;

&lt;p&gt;The Idris pretty-printer is based on &lt;a href="http://hackage.haskell.org/package/wl-pprint"&gt;wl-pprint&lt;/a&gt;, and its available as a mostly-API-compatible library on Hackage called &lt;a href="http://hackage.haskell.org/package/annotated-wl-pprint"&gt;annotated-wl-pprint&lt;/a&gt;. Please refer to the original library documentation or to Phil Wadler&amp;#8217;s paper "A Prettier Printer" for the basics of the approach. Rendering, in &lt;span class="stt"&gt;wl-pprint&lt;/span&gt;, converts a &lt;span class="stt"&gt;Doc&lt;/span&gt; to a &lt;span class="stt"&gt;SimpleDoc&lt;/span&gt;, which is specialized to a particular output width. Then, various functions are available to convert a &lt;span class="stt"&gt;SimpleDoc&lt;/span&gt; to a &lt;span class="stt"&gt;String&lt;/span&gt; and to write it to an output strea in &lt;span class="stt"&gt;IO&lt;/span&gt;. In &lt;span class="stt"&gt;annotated-wl-pprint&lt;/span&gt;, both &lt;span class="stt"&gt;Doc&lt;/span&gt; and &lt;span class="stt"&gt;SimpleDoc&lt;/span&gt; are parameterized over annotations, and additional &lt;span class="stt"&gt;String&lt;/span&gt;-rendering functions are available that can use the semantic information.&lt;/p&gt;

&lt;p&gt;The original rendering functions are still available in &lt;span class="stt"&gt;annotated-wl-pprint&lt;/span&gt;: they merely discard the annotations. However, two new rendering functions are available. The first, called &lt;span class="stt"&gt;displayDecorated&lt;/span&gt;, take a decorator function with type &lt;span class="stt"&gt;a -&amp;gt; String -&amp;gt; String&lt;/span&gt; as an argument, and uses this to rewrite each substring as it is generated. This function is used in Idris to generated console output. The second, called &lt;span class="stt"&gt;displaySpans&lt;/span&gt;, generates a pair consisting of the ordinary string representation as well as a list of text spans and their corresponding annotations. This is used in Idris to generate machine-readable IDE output.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Doc_and_.Simple.Doc_are_.Functors)"&gt;&lt;/a&gt;Doc and SimpleDoc are Functors&lt;/h1&gt;

&lt;p&gt;The constructors of &lt;span class="stt"&gt;Doc a&lt;/span&gt; and &lt;span class="stt"&gt;SimpleDoc a&lt;/span&gt; are not exported, as they must maintain some invariants that the combinator language ensures. However, they have instances of &lt;span class="stt"&gt;Functor&lt;/span&gt;, which means that post-processing and rendering of user representations of the semantic annotations is just an &lt;span class="stt"&gt;fmap&lt;/span&gt; away. This is very useful in Idris, and I would like to thank &lt;a href="http://www.flippac.org/"&gt;Philippa Cowderoy&lt;/a&gt; for pointing out to me on IRC that pretty-printer documents are in fact functors.&lt;/p&gt;

&lt;p&gt;For example, when the pretty-printer encounters a global name in a term, it simply saves its fully-qualified form in an annotation. Later, we can add the additional information (such as documentation summaries and type signatures) that is sent to IDEs. This enables the pretty-printer to be independent of the global definition context in Idris, enabling greater modularity. Additionally, the type system can be used to ensure that various processing steps have been carried out, although this could use some refactoring in Idris at the moment.&lt;/p&gt;

&lt;p&gt;This structure enables a clean separation between the pretty-printing of textual output and the processing of semantic information. Additionally, the technique is also useful when displaying documentation, where parsed Markdown formatting information is inserted in the strings to be displayed, and to associate source locations in error messages with a declarative specification of the full filename and line and column numbers.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Active_.Terms_in_.Idris)"&gt;&lt;/a&gt;Active Terms in Idris&lt;/h1&gt;

&lt;p&gt;In the demo that I linked to at the top of this post, you can see editor commands to show the implicit arguments to already-printed terms and to normalize them on demand. This is implemented by annotating subterms in the output record with a serialized representation of their corresponding term in Idris&amp;#8217;s core language, as well as some information about the names available in their scope. These terms are then attached as a semantic annotation. When these annotations are rendered for IDE clients, they are base64-encoded.&lt;/p&gt;

&lt;p&gt;Idris&amp;#8217;s IDE protocol has commands that can manipulate these encoded terms, pretty-printing them with various options, potentially after normalization. Naturally, these commands annotate their output with a serialized representation of the resulting term, allowing them to be used again.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Remaining)"&gt;&lt;/a&gt;Remaining&lt;/h1&gt;

&lt;p&gt;The current implementation of &lt;span class="stt"&gt;annotated-wl-pprint&lt;/span&gt; is lacking one important rendering function, which would allow actions in a monad to delimit output strings. This would enable the display of semantic colors on terminals in Windows, which don&amp;#8217;t support ANSI color codes. Additionally, I&amp;#8217;m quite sure that I can attach more information that would be useful.&lt;/p&gt;

&lt;p&gt;Do you have any nifty ideas for &lt;span class="stt"&gt;idris-mode&lt;/span&gt;? Are you working on Idris support from another editor? Is there something in the above that should be done a better way? Do you need help using &lt;span class="stt"&gt;annotated-wl-pprint&lt;/span&gt; in your own project? Please don&amp;#8217;t hesitate to get in touch!&lt;/p&gt;

&lt;p&gt;&lt;span class="Larger"&gt;&lt;span style="font-weight: bold"&gt;Update, 26 January, 2015&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Trevor Elliott has implemented annotation support for the &lt;a href="https://github.com/haskell/pretty"&gt;pretty&lt;/a&gt; library, which has a Hughes-PJ-style interface, so if your project uses that API, you can more easily begin to use semantic annotations. See &lt;a href="https://github.com/haskell/pretty/pull/19"&gt;pull request #19&lt;/a&gt; for the gory details.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Comments)"&gt;&lt;/a&gt;Comments&lt;/h1&gt;

&lt;p&gt;
 &lt;article class="comment-body"&gt;
  &lt;footer class="comment-meta"&gt;
   &lt;div class="comment-author"&gt;
    &lt;div class="gravatar" style="width: 64px; height: 64px; background: url(http://www.gravatar.com/avatar/9f57a0b8bcfd77585fa2fd171455054e?d=identicon&amp;amp;s=64);"&gt;&lt;/div&gt;
    &lt;div class="comment-metadata"&gt;&lt;span class="fn"&gt;carlos&lt;/span&gt;
     &lt;time datetime="2014-09-07T22:32:00Z"&gt;2014-09-07 22:32&lt;/time&gt;&lt;/div&gt;&lt;/div&gt;&lt;/footer&gt;
  &lt;div class="comment-content"&gt;Last time I needed coloured output from a Haskell program I defined some simple readable colour codes that were used throughout the code, something like "Text in !1red!7 and !4blue". Then I added a final step that output the text using System.Console.ANSI so it worked on both Windows and Linux without complicating the structure of your code.&lt;/div&gt;&lt;/article&gt;&lt;/p&gt;

&lt;p&gt;
 &lt;article class="comment-body"&gt;
  &lt;footer class="comment-meta"&gt;
   &lt;div class="comment-author"&gt;
    &lt;div class="gravatar" style="width: 64px; height: 64px; background: url(http://www.gravatar.com/avatar/c7da8df7d8cb6a6d1b9ad052a20eb54d?d=identicon&amp;amp;s=64);"&gt;&lt;/div&gt;
    &lt;div class="comment-metadata"&gt;&lt;span class="fn"&gt;Simon Peyton Jones&lt;/span&gt;
     &lt;time datetime="2014-09-09T12:27:00Z"&gt;2014-09-09 12:27&lt;/time&gt;&lt;/div&gt;&lt;/div&gt;&lt;/footer&gt;
  &lt;div class="comment-content"&gt;This is a very neat idea. I hope that someone implements something like it for GHC.

   &lt;br /&gt;

   &lt;br /&gt;
Simon&lt;/div&gt;&lt;/article&gt;&lt;/p&gt;</description></item>
  <item>
   <title>New paper submission: "Type-Directed Elaboration of Quasiquotations: A High-Level Syntax for Low-Level Reflection"</title>
   <link>http://www.davidchristiansen.dk/2014/08/20/new-paper-submission-type-directed-elaboration-of-quasiquotations-a-high-level-syntax-for-low-level-reflection</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-08-20-new-paper-submission-type-directed-elaboration-of-quasiquotations-a-high-level-syntax-for-low-level-reflection</guid>
   <pubDate>Wed, 20 Aug 2014 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;I just finished a submission to &lt;a href="http://ifl2014.github.io/"&gt;IFL 2014&lt;/a&gt;. It&amp;#8217;s a paper about Idris&amp;rsquo;s quasiquotations mechanism, which allow the use of high-level Idris syntax to describe low-level reflected terms, with the ability to escape from quotation in chosen areas and intentionally control the details of the representation. This is very much inspired by Lisp quasiquotation.&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;You can find the paper on &lt;a href="http://www.itu.dk/people/drc"&gt;my academic page&lt;/a&gt;. Because of the IFL submission process, I have ample time to make changes, so if I&amp;#8217;ve made a mistake or failed to explain something clearly, I&amp;#8217;d love to hear about it!&lt;/p&gt;</description></item>
  <item>
   <title>New Podcast on Type Theory</title>
   <link>http://www.davidchristiansen.dk/2014/08/13/new-podcast-on-type-theory</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-08-13-new-podcast-on-type-theory</guid>
   <pubDate>Wed, 13 Aug 2014 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;I&amp;#8217;m a cohost of a new pocast on type theory, &lt;a href="http://typetheorypodcast.com/"&gt;The Type Theory Podcast&lt;/a&gt;. We just posted our first episode: &lt;a href="http://typetheorypodcast.com/2014/08/episode-1-peter-dybjer-on-type-theory-and-testing/"&gt;an interview with Peter Dybjer&lt;/a&gt; on types and testing.&lt;/p&gt;</description></item>
  <item>
   <title>Implementing an Emacs programming language mode: beyond the basics</title>
   <link>http://www.davidchristiansen.dk/2014/07/16/implementing-an-emacs-programming-language-mode-beyond-the-basics</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-07-16-implementing-an-emacs-programming-language-mode-beyond-the-basics</guid>
   <pubDate>Wed, 16 Jul 2014 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;As one of the two primary authors of &lt;a href="https://www.github.com/idris-hackers/idris-mode"&gt;idris-mode&lt;/a&gt;, I&amp;#8217;ve had to learn a fair bit about implementing Emacs modes. While I&amp;#8217;m far from an expert on the subject, I do think that I&amp;#8217;ve picked up a few ideas that are useful. There are already a number of good tutorials about the very basics, such as &lt;span class="stt"&gt;define-derived-mode&lt;/span&gt;, &lt;span class="stt"&gt;font-lock&lt;/span&gt;, and Emacs packages. What I haven&amp;#8217;t been able to find is an answer to the question &amp;#8220;what&amp;#8217;s next?&amp;#8221;. You can view this post as a kind of checklist for useful things to add to your mode.&lt;/p&gt;

&lt;p&gt;I won&amp;#8217;t go into great detail about how to do all of these things, because the documentation is typically quite good. The real problem is learning that there is documentation to be read!&lt;/p&gt;
&lt;!--more--&gt;

&lt;h1&gt;&lt;a name="(part._.Imenu)"&gt;&lt;/a&gt;Imenu&lt;/h1&gt;

&lt;p&gt;While many Emacs users turn off the menu bar entirely, making Imenu not particularly attractive, it pays to support it anyway. This is because lots of other features in Emacs use Imenu as a data source. For example, speedbar will use it to show an index of your file and &lt;span class="stt"&gt;which-func-mode&lt;/span&gt; uses it to determine what to show in your mode line.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Completion)"&gt;&lt;/a&gt;Completion&lt;/h1&gt;

&lt;p&gt;These days, it is very straightforward to implement completion for your mode. Many older modes contain complicated code to show completion buffers, restoring window configurations afterwards. In Emacs 24, we have &lt;span class="stt"&gt;completion-at-point&lt;/span&gt;. Simply ensure that this is bound to something (often &lt;span class="stt"&gt;M-TAB&lt;/span&gt;), and then arrange for it to have enough information to present good completions&lt;/p&gt;

&lt;p&gt;The variable &lt;span class="stt"&gt;completion-at-point-functions&lt;/span&gt; provides the raw data that completion-at-point will use to construct a completions buffer. The variable contains a list of 0-argument functions, each of which should return either nil or a collection of completion candidates. Emacs takes care of all the tedious organization of buffers. In &lt;span class="stt"&gt;idris-mode&lt;/span&gt;, we simply delegate to the compiler to provide completion candidates.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Eldoc)"&gt;&lt;/a&gt;Eldoc&lt;/h1&gt;

&lt;p&gt;Eldoc is a minor mode for showing documentation strings in the echo area. By default, it supports Emacs Lisp, but it&amp;#8217;s quite straightfoward to make it work for your language. All you need is a function that returns either a docstring for the symbol at point or nil. In the case of Idris, we already had a command to ask the compiler for a type signature, so it was especially easy. Once you have this function, just set &lt;span class="stt"&gt;eldoc-documentation-function&lt;/span&gt; to its name and place &lt;span class="stt"&gt;turn-on-eldoc-mode&lt;/span&gt; in your default mode hook.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="SIntrapara"&gt;Here&amp;#8217;s the function from idris-mode:
&lt;/div&gt;

&lt;div class="SIntrapara"&gt;
 &lt;table cellpadding="0" cellspacing="0"&gt;
  &lt;tbody&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;(defun idris-eldoc-lookup ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Support for showing type signatures in the modeline when there's a running Idris"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(let ((signature (ignore-errors (idris-eval (list :type-of (idris-name-at-point))))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(when signature&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(with-temp-buffer&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(idris-propertize-spans (idris-repl-semantic-text-props (cdr signature))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(insert (car signature)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(buffer-string)))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;div class="SIntrapara"&gt;All of the &lt;span class="stt"&gt;idris-propertize-spans&lt;/span&gt; stuff is to apply font information from the compiler.&lt;/div&gt;

&lt;h1&gt;&lt;a name="(part._.Flycheck)"&gt;&lt;/a&gt;Flycheck&lt;/h1&gt;

&lt;p&gt;Flycheck is a minor mode that runs quick external programs on the contents of your buffer, annotating the buffer with any warnings produced, without you needing to save the buffer. It is fairly straightforward to define a checker for Flycheck, and it can be added to your mode without disturbing users who don&amp;#8217;t use Flycheck by wrapping it up in an &lt;span class="stt"&gt;eval-after-load&lt;/span&gt;. Here is the entire checker from &lt;span class="stt"&gt;idris-mode&lt;/span&gt;, written by Brian McKenna:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;;###autoload&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(eval-after-load 'flycheck&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;'(progn&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(flycheck-define-checker idris&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"An Idris syntax and type checker."&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:command ("idris" "--check" "--nocolor" "--warnpartial" source)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:error-patterns&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;((warning line-start (file-name) ":" line ":" column ":Warning - "&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(message (and (* nonl) (* "\n" (not (any "/" "~")) (* nonl)))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(error line-start (file-name) ":" line ":" column ":"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(message (and (* nonl) (* "\n" (not (any "/" "~")) (* nonl))))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:modes idris-mode)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(add-to-list 'flycheck-checkers 'idris)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;h1&gt;&lt;a name="(part._.Customize)"&gt;&lt;/a&gt;Customize&lt;/h1&gt;

&lt;p&gt;In my opinion, it&amp;#8217;s important to have variables that control settings for a mode be separate from other variables, so that users can see what they&amp;#8217;re intended to change and what they are not. A good way to indicate that a variable is intended for user customization is to make it available through customize. When thinking about how to customize features of your mode, consider how to organize them into groups so that they are easy to find.&lt;/p&gt;

&lt;p&gt;If you define your mode as a derive mode (and you should), remember to pass the &lt;span class="stt"&gt;:group&lt;/span&gt; option to &lt;span class="stt"&gt;define-derived-mode&lt;/span&gt;. This makes the standard command &lt;span class="stt"&gt;customize-mode&lt;/span&gt; work.&lt;/p&gt;

&lt;p&gt;Additionally, your mode should really avoid using built-in faces. Instead, define your own faces with &lt;span class="stt"&gt;defface&lt;/span&gt; and set them to inherit from the built-in faces that you were thinking of using. This lets your users decide how they want to see your mode. Good defaults are also important, to the extent that you can have them, so pay attention to built-in faces that you can inherit from, which will make your mode automatically conform to the user&amp;#8217;s color theme. Perhaps the biggest source of complaints about &lt;span class="stt"&gt;idris-mode&lt;/span&gt; has come from default colors that don&amp;#8217;t look good for users, where I was unable to find a built-in face to inherit from that makes sense. Surprisingly many Emacs users don&amp;#8217;t know that they can easily customize a face.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Prog_mode)"&gt;&lt;/a&gt;Prog mode&lt;/h1&gt;

&lt;p&gt;Remember to derive your mode from &lt;span class="stt"&gt;prog-mode&lt;/span&gt;. If you don&amp;#8217;t do that, at least make sure that you call &lt;span class="stt"&gt;prog-mode-hook&lt;/span&gt;. This allows Emacs users to set things up for every programming language mode, while not using these settings in other places. This is useful for things like showing trailing whitespace or turning on line numbering.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.Common_.Lisp_features)"&gt;&lt;/a&gt;Common Lisp features&lt;/h1&gt;

&lt;p&gt;If you have experience writing Common Lisp code, you&amp;#8217;re in for a disappointment when you write Emacs Lisp. There are many, many useful features, such as &lt;span class="stt"&gt;destructuring-bind&lt;/span&gt;, that Emacs Lisp just doesn&amp;#8217;t support. Furthermore, when these features are available, you either have to use a compile-time-only macro package (&lt;span class="stt"&gt;cl&lt;/span&gt;) or an ugly prefixed version (&lt;span class="stt"&gt;cl-lib&lt;/span&gt;). I recommend the latter, as you avoid having to worry about which features are macros and which are functions. Unfortunately, you will probably end up with &lt;span class="stt"&gt;cl&lt;/span&gt; loaded by something in your initialization file, so Emacs will probably not complain if you accidentally use &lt;span class="stt"&gt;cl&lt;/span&gt; names instead of cl-lib names, which can lead to problems for your users. Consider using &lt;span class="stt"&gt;cl-lib-highlight&lt;/span&gt; to get warnings in your Lisp buffers when you use un-prefixed &lt;span class="stt"&gt;cl&lt;/span&gt; symbols.&lt;/p&gt;

&lt;h1&gt;&lt;a name="(part._.All_the_rest)"&gt;&lt;/a&gt;All the rest&lt;/h1&gt;

&lt;p&gt;After you&amp;#8217;ve got these things done, then it&amp;#8217;s time to start attacking all the little things, like getting the parsing working for motion commands such as forward-sexp, implementing fill-paragraph for comments and docstrings, and so forth. I haven&amp;#8217;t done all these things yet, but I&amp;#8217;ll write it up if I find a nice strategy.&lt;/p&gt;

&lt;p&gt;
 &lt;article class="comment-body"&gt;
  &lt;footer class="comment-meta"&gt;
   &lt;div class="comment-author"&gt;
    &lt;div class="gravatar" style="width: 64px; height: 64px; background: url(http://www.gravatar.com/avatar/da4b6e45576718c12386b1636497e3d0?d=identicon&amp;amp;s=64);"&gt;&lt;/div&gt;
    &lt;div class="comment-metadata"&gt;&lt;span class="fn"&gt;David Christiansen&lt;/span&gt;
     &lt;time datetime="2015-03-06T10:25:00Z"&gt;2015-03-06 10:25&lt;/time&gt;&lt;/div&gt;&lt;/div&gt;&lt;/footer&gt;
  &lt;div class="comment-content"&gt;
There are some useful comments about this post in &lt;a href="http://www.reddit.com/r/emacs/comments/2frtfr/implementing_an_emacs_programming_language_mode/"&gt;a Reddit discussion&lt;/a&gt;.

   &lt;br /&gt;

   &lt;br /&gt;
First off, the candidates returned from a member of &lt;span class="stt"&gt;completion-at-point-functions&lt;/span&gt; need to have some additional information about string locations and can have some properties &amp;#8211; make sure to read the documentation!


   &lt;br /&gt;

   &lt;br /&gt;

Also, &lt;span class="stt"&gt;pcase-let&lt;/span&gt; is a reasonable substitute for &lt;span class="stt"&gt;destructuring-bind&lt;/span&gt;.


   &lt;br /&gt;

   &lt;br /&gt;

Finally, make sure to have a test infrastructure set up that byte-compiles your mode in a clean Emacs. This will help catch &lt;span class="stt"&gt;cl&lt;/span&gt; errors along with all kinds of other issues. Additionally, use &lt;span class="stt"&gt;flycheck-mode&lt;/span&gt; while writing your package to catch more errors at that time.
&lt;/div&gt;&lt;/article&gt;&lt;/p&gt;</description></item>
  <item>
   <title>Techniques for using decision procedures in Idris</title>
   <link>http://www.davidchristiansen.dk/2014/05/21/techniques-for-using-decision-procedures-in-idris</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2014-05-21-techniques-for-using-decision-procedures-in-idris</guid>
   <pubDate>Wed, 21 May 2014 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>&lt;!--more--&gt;

&lt;p&gt;This post is a literate Idris file, so first let&amp;#8217;s get some bureaucracy out of the way:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;module LT&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;%default total&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;When writing Idris code, we sometimes need a proof as an argument to a function. In many cases, these proofs can be constructed automatically by a decision procedure. Here, I&amp;#8217;m using the term "decision procedure" for some property &lt;span class="stt"&gt;p&lt;/span&gt; to refer to a function that returns something in the type &lt;span class="stt"&gt;Dec p&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;An instance of &lt;span class="stt"&gt;Dec p&lt;/span&gt; is either a proof of &lt;span class="stt"&gt;p&lt;/span&gt; or a proof that &lt;span class="stt"&gt;p&lt;/span&gt; is an absurdity. The datatype is defined as follows:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;data Dec : Type -&amp;gt; Type where&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;Yes : p -&amp;gt; Dec p&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;No : (p -&amp;gt; _|_) -&amp;gt; Dec p&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;As an example, take the following type from the Idris library that represents a proof that one natural number is less than or equal to another:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;data LTE : Nat -&amp;gt; Nat -&amp;gt; Type where&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;lteZero : LTE 0 m&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;lteSucc : LTE n m -&amp;gt; LTE (S n) (S m)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The first constructor, &lt;span class="stt"&gt;lteZero&lt;/span&gt;, should be interpreted as an assertion that zero is less than or equal to any natural number. The second, &lt;span class="stt"&gt;lteSucc&lt;/span&gt;, is an assertion that if n&amp;#8804;m, then n+1 &amp;#8804; m+1. It happens to be the case that, for any two natural numbers, it is decidable whether the first is less than or equal to the second.&lt;/p&gt;

&lt;p&gt;To prove this, we start with two simple lemmas. The first states that it is not the case that the successor of any number is less than or equal to zero:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;notLTESZ : LTE (S k) Z -&amp;gt; _|_&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;notLTESZ lteZero impossible&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Additionally, we show that, if k&amp;#8816;j, then k+1 &amp;#8816; j+1:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;notLTE_S_S : (LTE k j -&amp;gt; _|_) -&amp;gt; LTE (S k) (S j) -&amp;gt; _|_&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;notLTE_S_S nope (lteSucc x) = nope x&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;We are now in a position to write the decision procedure, by examining each case and using our lemmas to produce the appropriate contents for the &lt;span class="stt"&gt;No&lt;/span&gt; constructor. If the details don&amp;#8217;t make sense, then please fire up Idris, replace some right-hand sides with metavariables, and examine the proof context.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;decLTE : (n,m : Nat) -&amp;gt; Dec (n `LTE` m)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;decLTE Z m = Yes lteZero&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;decLTE (S k) Z = No notLTESZ&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;decLTE (S k) (S j) with (decLTE k j)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;decLTE (S k) (S j) | (Yes prf) = Yes (lteSucc prf)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;decLTE (S k) (S j) | (No contra) = No $ notLTE_S_S contra&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Now that these details are out of the way, we can get to the main point of this blog post: demonstrating various techniques for getting Idris to fill out these proofs for us.&lt;/p&gt;

&lt;p&gt;The most straightforward way is to use the interactive editing features to get Idris to construct the proof term directly. For example, if we want to show that 3 &amp;#8804; 5, then we need only create a definition with type &lt;span class="stt"&gt;3 &lt;/span&gt;&lt;span class="stt"&gt;&amp;lsquo;&lt;/span&gt;&lt;span class="stt"&gt;LTE&lt;/span&gt;&lt;span class="stt"&gt;&amp;lsquo;&lt;/span&gt;&lt;span class="stt"&gt; 5&lt;/span&gt;:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;ok : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;We can then use &lt;span class="stt"&gt;C-c C-s&lt;/span&gt; in &lt;span class="stt"&gt;idris-mode&lt;/span&gt; to cause it to become&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;ok : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;ok = ?ok_rhs&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Using the proof search command &lt;span class="stt"&gt;C-c C-a&lt;/span&gt; on the metavariable gives us&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;ok : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;ok = lteSucc (lteSucc (lteSucc lteZero))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;and the decision procedure simply isn&amp;#8217;t necessary. This approach can make our programs ugly, but it is straightforward and direct. We need not actually show the resulting term, however. In Idris, tactic scripts are allowed as the right-hand side of definitions. So we can simply invoke the search tactic explicitly, rather than using it through the compiler&amp;#8217;s editor interface, and the resulting term does not need to occur in the source file. This can also be more robust in the face of changes to the definition of &lt;span class="stt"&gt;LTE&lt;/span&gt;. The tactic-based definition is:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okTactic : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okTactic = proof search&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Here, &lt;span class="stt"&gt;proof&lt;/span&gt; begins a tactic script, and search is the tactic to be invoked.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="SIntrapara"&gt;Using Idris&amp;#8217;s built-in proof search has two major limitations:
&lt;/div&gt;

&lt;div class="SIntrapara"&gt;
 &lt;ol&gt;
  &lt;li&gt;
   &lt;p&gt;It cannot solve more "interesting" goals, in which a simple recursive application of constructors is insufficient&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;
   &lt;p&gt;It fails to find large goals, as the recursion depth is limited. For example, it cannot solve 103 &amp;lsquo;LTE&amp;lsquo; 105.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;

&lt;div class="SIntrapara"&gt;What we really want to do is use &lt;span class="stt"&gt;decLTE&lt;/span&gt; to find the term.&lt;/div&gt;

&lt;p&gt;One non-solution is to have the right-hand side of the definition perform a case analysis on the result of a call to &lt;span class="stt"&gt;decLTE&lt;/span&gt;, and then return the contents of the &lt;span class="stt"&gt;Yes&lt;/span&gt; case. Because we know that three is, in fact, less than five, we will never need the &lt;span class="stt"&gt;No&lt;/span&gt; case:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okCase : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okCase = case decLTE 3 5 of&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;Yes prf =&amp;gt; prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Unfortunately, the Idris compiler needs to be convinced of the fact that &lt;span class="stt"&gt;No&lt;/span&gt; cannot occur. We do this by showing that the &lt;span class="stt"&gt;No&lt;/span&gt; case could cause the empty type to be inhabited, and then use FalseElim. Unfortunately, doing this requires actually proving the property again:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="SIntrapara"&gt;
 &lt;table cellpadding="0" cellspacing="0"&gt;
  &lt;tbody&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;okCase : 3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;okCase = case decLTE 3 5 of&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;Yes prf =&amp;gt; prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;No nope =&amp;gt; FalseElim . nope $ lteSucc (lteSucc (lteSucc lteZero))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;div class="SIntrapara"&gt;So this method is a non-starter.&lt;/div&gt;

&lt;p&gt;The next method is to cause the solver for implicit arguments to execute the decision procedure while filling out an implicit argument for the proof, and then return this implicit argument. The definition &lt;span class="stt"&gt;okImplicit&lt;/span&gt; demonstrates this technique:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okImplicit : 103 `LTE` 105&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okImplicit&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;= getProof&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;where getProof : {prf : LTE 103 105} -&amp;gt; {auto yep : decLTE 103 105 = Yes prf} -&amp;gt; 103 `LTE` 105&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;getProof {prf} = prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;All of the work happens in &lt;span class="stt"&gt;getProof&lt;/span&gt;, which is in a where block to keep the type signature of &lt;span class="stt"&gt;okImplicit&lt;/span&gt; clean. In the definition of &lt;span class="stt"&gt;getProof&lt;/span&gt;, the implicit argument &lt;span class="stt"&gt;prf&lt;/span&gt; is the one that will be filled out with the proof, and then returned. The argument &lt;span class="stt"&gt;yep&lt;/span&gt; is an implicit proof that the result of executing the decision procedure will be &lt;span class="stt"&gt;Yes prf&lt;/span&gt; &amp;#8211; in other words, that it will succeed, and the thing it succeeds with will unify with &lt;span class="stt"&gt;prf&lt;/span&gt;. The &lt;span class="stt"&gt;auto&lt;/span&gt; keyword causes Idris to fill out the argument with &lt;span class="stt"&gt;refl&lt;/span&gt;, the constructor of proofs of equality.&lt;/p&gt;

&lt;p&gt;While the &lt;span class="stt"&gt;okImplici&lt;/span&gt;t technique leads to noisy boilerplate in type signatures, it also tends to cause error messages that are easy to understand. I&amp;#8217;ve had a lot of luck using it for embedded DSLs with some kind of side condition (like "these queries must have disjoint schemas").&lt;/p&gt;

&lt;p&gt;The final technique that I&amp;#8217;d like to demonstrate uses a dependently-typed extractor of proofs from Dec. The type of the function &lt;span class="stt"&gt;getYes&lt;/span&gt; does case-analysis on the result of a decision procedure. If the result was &lt;span class="stt"&gt;Yes&lt;/span&gt;, then &lt;span class="stt"&gt;getYes&lt;/span&gt; will return the contents &amp;#8211; an instance of &lt;span class="stt"&gt;p&lt;/span&gt;. Otherwise, it returns unit, which contains no interesting information. Note that the result of the case expression is a type &amp;#8212; either the type parameter to &lt;span class="stt"&gt;Dec&lt;/span&gt; or the unit type.&lt;/p&gt;

&lt;p&gt;getYes : (res : Dec p) -&amp;gt; case res of { Yes _ =&amp;gt; p ; No _ =&amp;gt; () }&lt;/p&gt;

&lt;p&gt;The body of &lt;span class="stt"&gt;getYes&lt;/span&gt; performs a case analysis on the result of the decision, either returning a proof or a trivial value, in accordance with the type. Note that Idris&amp;#8217;s interactive editing features were able to write this code entirely &amp;#8211; the only thing I needed to do was tell it to case split on the argument. Agda, which has more advanced interactive editing features, could probably write the entire body by passing Agsy the -c option, which enables case splitting.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;getYes (Yes prf) = prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;getYes (No contra) = ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Now, &lt;span class="stt"&gt;getYes&lt;/span&gt; can be used on the right-hand side of our definition to extract the proof:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okYes :&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;3 `LTE` 5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;okYes = getYes (decLTE 3 5)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;While this approach is clean, the error messages can be somewhat unpleasant if Idris is asked to prove a falsehood. The following code:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;oops :&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;5 `LTE` 3&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;oops = getYes (decLTE 5 3)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;results in this unification error:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;When elaborating right hand side of oops:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;Can't unify&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;case block in getYes (LTE (fromInteger 5) (fromInteger 3)) (decLTE (fromInteger 5) (fromInteger 3)) (decLTE (fromInteger 5) (fromInteger 3))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;with&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;LTE 5 3&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;Specifically:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;Can't unify&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;case block in getYes (LTE (fromInteger 5) (fromInteger 3)) (decLTE (fromInteger 5) (fromInteger 3)) (decLTE (fromInteger 5) (fromInteger 3))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;with&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;LTE 5 3&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;whereas the error message from&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;badImplicit : 105 `LTE` 103&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;badImplicit&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;= getProof&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;where getProof : {prf : LTE 105 103} -&amp;gt; {auto yep : decLTE 105 104 = Yes prf} -&amp;gt; 105 `LTE` 103&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;getProof {prf} = prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;was&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;When elaborating right hand side of badImplicit:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;When elaborating argument yep to LT.badImplicit, getProof:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;Can't solve goal&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;decLTE (fromInteger 105) (fromInteger 104) = Yes prf&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;You have now seen a few ways of getting Idris to find proofs. Hopefully, you&amp;#8217;ve also gotten a bit more understanding of how Idris works while compiling your source file.&lt;/p&gt;

&lt;p&gt;This post sprang out of a discussion on a Github issue with Nicola Botta. The discussion of error messages is improved as the result of a suggestion from Anthony Cowley. Thanks, Nicola and Anthony!&lt;/p&gt;</description></item>
  <item>
   <title>New tutorial on bidirectional typing rules</title>
   <link>http://www.davidchristiansen.dk/2013/10/16/new-tutorial-on-bidirectional-typing-rules</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2013-10-16-new-tutorial-on-bidirectional-typing-rules</guid>
   <pubDate>Wed, 16 Oct 2013 07:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;I&amp;#8217;ve just written a new tutorial on bidirectional typing rules. It&amp;#8217;s available from &lt;a href="/tutorials"&gt;my tutorials page&lt;/a&gt;. The PDF can also be &lt;a href="/tutorials/bidirectional.pdf"&gt;downloaded directly&lt;/a&gt;.&lt;/p&gt;</description></item>
  <item>
   <title>Tutorials on my ITU page</title>
   <link>http://www.davidchristiansen.dk/2012/12/20/tutorials-on-my-itu-page</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2012-12-20-tutorials-on-my-itu-page</guid>
   <pubDate>Thu, 20 Dec 2012 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;In case you&amp;#8217;re interested in programming languages and you&amp;#8217;re working from Peter Sestoft&amp;#8217;s book &lt;a href="http://www.itu.dk/people/sestoft/plc/"&gt;Programming Language Concepts&lt;/a&gt;, I&amp;#8217;ve just posted some supplementary materials to my ITU page. It consists of a tutorial for converting from regular expressions to discrete finite automata via NFAs and a tutorial on constructing typing derivations in the particular miniature ML-like language used in the book.&lt;/p&gt;

&lt;p&gt;You can find them on my &lt;a href="/tutorials"&gt;tutorials&lt;/a&gt; page.&lt;/p&gt;</description></item>
  <item>
   <title>Using Scala libraries with new compiler versions</title>
   <link>http://www.davidchristiansen.dk/2012/01/24/using-scala-libraries-with-new-compiler-versions</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2012-01-24-using-scala-libraries-with-new-compiler-versions</guid>
   <pubDate>Tue, 24 Jan 2012 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;I recently needed to use Scalacheck with a milestone release of the compiler, and it took me a little while to wrap my head around the infrastructure. To preserve the steps for prosperity, I&amp;#8217;m documenting them here, as I couldn&amp;#8217;t find it described anywhere.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="SIntrapara"&gt;The first step is to understand the relationship between the various parts:
&lt;/div&gt;

&lt;div class="SIntrapara"&gt;
 &lt;ul&gt;
  &lt;li&gt;
   &lt;p&gt;SBT is responsible for compiling your project, running tests, and generally performing the same role as make or ant. It also uses Ivy for retrieving library dependencies.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;
   &lt;p&gt;Apache Ivy provides an infrastructure for dependency management. Libraries exist in repositories, similar to Debian package repositories, and they are available in multiple versions.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;

&lt;p&gt;When you add library dependencies in your project&amp;#8217;s SBT configuration, it will find the code by first looking in your local Ivy repository, then in any remote repositories that are configured. In other words, even if you don&amp;#8217;t have access to the remote repositories, you can still put libraries in your local repository to be found by SBT.&lt;/p&gt;

&lt;p&gt;Libraries such as Scalacheck that are intended to be used with multiple versions of Scala will typically use the &lt;span class="stt"&gt;crossScalaVersions&lt;/span&gt; setting to build against multiple compiler versions. The workflow to get a library working is, then:&lt;/p&gt;

&lt;ol&gt;
 &lt;li&gt;
  &lt;p&gt;Get ahold of the source code to the library&lt;/p&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;p&gt;In &lt;span class="stt"&gt;build.sbt&lt;/span&gt;, find the &lt;span class="stt"&gt;crossScalaVersions&lt;/span&gt; setting. Add the desired version of Scala.&lt;/p&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;p&gt;Run &lt;span class="stt"&gt;sbt&lt;/span&gt;. At the command line, type &lt;span class="stt"&gt;+ test&lt;/span&gt;. This will compile the project for each configured version of Scala and run the tests.&lt;/p&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;p&gt;Assuming the project passes, run &lt;span class="stt"&gt;+ publish-local&lt;/span&gt; to push the compiled version&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Now, the library will be available in your other projects.&lt;/p&gt;</description></item>
  <item>
   <title>Make Ensime work with newer versions of SBT</title>
   <link>http://www.davidchristiansen.dk/2011/12/20/make-ensime-work-with-newer-versions-of-sbt</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2011-12-20-make-ensime-work-with-newer-versions-of-sbt</guid>
   <pubDate>Tue, 20 Dec 2011 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;If you try to use &lt;a href="https://github.com/aemoncannon/ensime"&gt;Ensime&lt;/a&gt; with newer versions of &lt;a href="https://github.com/harrah/xsbt"&gt;SBT&lt;/a&gt;, you&amp;#8217;ll find that SBT grows to fill available memory and then crashes. This is because the latest released version of Ensime assumes the project format of an old version of SBT. To fix this, just add the following to your .emacs after you require Ensime:&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defun ensime-sbt-project-dir-p (path)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Does a build.sbt or a project/build.properties exists in the given path."&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(or (file-exists-p (concat path "/build.sbt"))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(file-exists-p (concat path "/project/build.properties"))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The problem occurs because Ensime looks for your project directory by recursively going to parent directories until it sees something that looks like an SBT project. Eventually, it ends up in root, and SBT crashes while trying to recursively enumerate all the files in the current directory. Redefining this function to also look for newer project formats fixes the issue.&lt;/p&gt;</description></item>
  <item>
   <title>Emacs code for fetching a bibliography in BibTeX form from CiteULike</title>
   <link>http://www.davidchristiansen.dk/2011/12/12/emacs-code-for-fetching-a-bibliography-in-bibtex-form-from-citeulike</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2011-12-12-emacs-code-for-fetching-a-bibliography-in-bibtex-form-from-citeulike</guid>
   <pubDate>Mon, 12 Dec 2011 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;I typically manage my references with CiteULike. My typical workflow is to add the articles that I&amp;#8217;m interested in, and then while writing, keep a complete copy of the exported BibTeX next to the LaTeX files. This gets tedious to maintain by hand, so I wrote this little chunk of elisp to download the file and name it the way I do.&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;To use, simply place it in a file called &lt;span class="stt"&gt;citeulike.el&lt;/span&gt; on your &lt;span class="stt"&gt;load-path&lt;/span&gt; and add &lt;span class="stt"&gt;(require &amp;#8216;citeulike)&lt;/span&gt; to your &lt;span class="stt"&gt;.emacs&lt;/span&gt;. Make sure to look at the customization options. Then, run &lt;span class="stt"&gt;M-x citeulike-download-bibtex&lt;/span&gt; in your LaTeX buffer.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;;; citeulike.el --- Getting things from CiteULike while working in AUCTeX&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;; Copyright (C) 2011 David Christiansen&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;; Author: David Christiansen&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; This program is free software: you can redistribute it and/or&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; modify it under the terms of the GNU General Public License as&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; published by the Free Software Foundation; either version 3 of the&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; This program is distributed in the hope that it will be useful,&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;See the GNU&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; General Public License for more details.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; You should have received a copy of the GNU General Public License&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; along with GNU Emacs; see the file COPYING.&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;If not, write to the&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; Boston, MA 02111-1307, USA.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;; Commentary:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; Purpose:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;; To make downloading an updated copy of references from CiteULike easier.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;;;; Code:&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(provide 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defgroup citeulike nil&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Options for CiteULike support"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:prefix 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-username ""&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"CiteULike username, used for downloading BibTeX exports."&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type 'string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-export-username-prefix nil&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Whether to add a username prefix to keys"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type '(choice (const :tag "Yes" t)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "No" nil))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-export-key-type 0&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"What kind of keys to put in the exported BibTeX"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type '(choice (const :tag "Prefer personal key; otherwise use numeric key" 0)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Prefer personal key; otherwise use AuthorYearTitle key" 4)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Prefer numeric keys" 1)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Only export articles with a personal key" 2)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Export both keys" 3))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-export-include-amazon-link nil&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Include Amazon links for books in exported BibTeX"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type '(choice (const :tag "Yes" t)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "No" nil))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-export-clean-urls t&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Escape URLs for BibTeX?"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type '(choice (const :tag "Escaped URLs" t)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Don't escape URLs" nil))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defcustom citeulike-export-smart-wrap 0&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Work around BibTeX capitalization"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:type '(choice (const :tag "Don't wrap" 0)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Smart wrap whole field" 1)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(const :tag "Smart wrap individual words" 2))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;:group 'citeulike)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defun citeulike-export-url ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(concat "http://www.citeulike.org/bibtex/user/"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;citeulike-username "?"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"do_username_prefix=" (if citeulike-export-username-prefix "1" "0") "&amp;amp;"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"key_type=" (number-to-string citeulike-export-key-type) "&amp;amp;"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"incl_amazon=" (if citeulike-export-include-amazon-link "1" "0") "&amp;amp;"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"clean-urls=" (if citeulike-export-clean-urls "1" "0") "&amp;amp;"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"smart_wrap=" (number-to-string citeulike-export-smart-wrap)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defun citeulike-download-bibtex ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(interactive)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(let* ((extension (file-name-extension buffer-file-name))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(rest (file-name-sans-extension buffer-file-name))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(target (if (equal extension "tex")&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(concat rest ".bib")&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(read-file-name "Filename to save: "))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(if (or (equal citeulike-username "") (not (stringp citeulike-username)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(error "No valid CiteULike username is configured")&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(let* ((command (concat "wget \"" (citeulike-export-url) "\""&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;" -O " target))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(final-command (read-string "Command: " command)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(shell-command final-command)))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description></item>
  <item>
   <title>Loading the current buffer in F#</title>
   <link>http://www.davidchristiansen.dk/2011/11/11/loading-the-current-buffer-in-f</link>
   <guid isPermaLink="false">urn:http-www-davidchristiansen-dk:-2011-11-11-loading-the-current-buffer-in-f</guid>
   <pubDate>Fri, 11 Nov 2011 08:00:00 UT</pubDate>
   <author>David Christiansen</author>
   <description>
&lt;p&gt;My primary editor for use with F# is Emacs. One feature that I missed in F# mode was the ability to load the file corresponding to the current buffer. Here&amp;#8217;s some elisp to do it. Put this in your &lt;span class="stt"&gt;.emacs&lt;/span&gt; file, and then when you are editing an F# module you can load it at the toplevel by pressing &lt;span class="stt"&gt;C-c C-f&lt;/span&gt;.&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;&lt;/p&gt;

&lt;table cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(defun fsharp-load-buffer-file ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;"Load the filename corresponding to the present buffer in F# with #load"&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(interactive)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(require 'inf-fsharp)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(let* ((name buffer-file-name)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(command (concat "#load \"" name "\"")))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(when (buffer-modified-p)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(when (y-or-n-p (concat "Do you want to save \"" name "\" before loading it? "))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(save-buffer)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(save-excursion (fsharp-run-process-if-needed))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(save-excursion (fsharp-simple-send inferior-fsharp-buffer-name command))))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;(add-hook 'fsharp-mode-hook&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(lambda ()&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="stt"&gt;(define-key fsharp-mode-map "\C-c\C-f" 'fsharp-load-buffer-file)))&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
    &lt;p&gt;&lt;span class="stt"&gt;&lt;/span&gt;&lt;span class="hspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description></item></channel></rss>