<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" >

  <title>Erik L. Arneson — Writer and Software Developer</title>
  <subtitle>Erik L. Arneson is a freelance writer and software developer with WordPress experience. He is located in Portland, Oregon.</subtitle>
  <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator>
  <link href="https://arnesonium.com/feeds/ocaml.xml" rel="self" type="application/atom+xml" />
  <link href="https://arnesonium.com/" rel="alternate" type="text/html" />
  <updated>2026-06-18T15:03:10+00:00</updated>
  <id>https://arnesonium.com/feeds/ocaml.xml</id>
  <author>
    <name>Erik L. Arneson</name>
  </author>
      <entry>
        
        <title>Link Rodeo: Go Package Management and Boring Technology</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2015/04/link-rodeo-go-package-management-and-boring-technology/" rel="alternate" type="text/html" title="Link Rodeo: Go Package Management and Boring Technology" />
        <updated>2015-04-06T15:47:00+00:00</updated>
        <id>https://arnesonium.com/2015/04/link-rodeo-go-package-management-and-boring-technology</id>
          <category term="best-practices" />
        
          <category term="golang" />
        
          <category term="javascript" />
        
          <category term="management" />
        
          <category term="node-js" />
        
          <category term="ocaml" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2015/04/link-rodeo-go-package-management-and-boring-technology/">&lt;p&gt;Here are a number of interesting topics for you to think about this week.
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;I’ve been learning the &lt;a href=&quot;http://arnesonium.com/tag/golang/&quot; title=&quot;Go language&quot;&gt;Go programming language&lt;/a&gt; recently, and in the process I’ve been having conversations about it with friends and colleagues. Go has a unique package management system that has already caused me a number of headaches. The recommended method for taking care of package dependencies is lacking, at best. Over at Nerdbucket, my buddy Nerdmaster has written &lt;a href=&quot;http://blog.nerdbucket.com/go-dependency-freezing/article&quot; title=&quot;Go Dependency Freezing at Nerdbucket&quot; target=&quot;_blank&quot;&gt;a thoughtful piece about it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While I’m talking about new technology, I’d also like to contradict myself by agreeing with Dan McKinley’s great piece, &lt;a href=&quot;http://mcfunley.com/choose-boring-technology&quot; title=&quot;Choose Boring Technology by Dan McKinley&quot; target=&quot;_blank&quot;&gt;“Choose Boring Technology.”&lt;/a&gt; He argues that a project should be careful about adopting lots of new tools and technologies. It reminds me of a time recently when I was looking for a Node.js programmer, and one of the replies I got back was, “For us, Node.js is glue. Its ecosystem is still too young to support anything long-term. Libraries and packages move too fast to build a product that will need actual maintenance.” I’ve had the same feeling about many technologies I’ve wanted to try, such as &lt;a href=&quot;http://ocsigen.org/&quot; title=&quot;Ocsigen&quot; target=&quot;_blank&quot;&gt;Ocsigen for OCaml&lt;/a&gt;, which has a build system and API that is always several steps ahead of its documentation.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;&lt;em&gt;This post’s featured photo is courtesy of Flickr user &lt;a href=&quot;https://www.flickr.com/photos/municipiopinas/8161449094/&quot; target=&quot;_blank&quot;&gt;MunicipioPinas&lt;/a&gt;.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;</content>
      </entry>
    
      <entry>
        
        <title>An English-language Stemmer for OCaml</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/12/an-english-language-stemmer-for-ocaml/" rel="alternate" type="text/html" title="An English-language Stemmer for OCaml" />
        <updated>2014-12-29T16:47:38+00:00</updated>
        <id>https://arnesonium.com/2014/12/an-english-language-stemmer-for-ocaml</id>
          <category term="c" />
        
          <category term="ocaml" />
        
          <category term="opam" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2014/12/an-english-language-stemmer-for-ocaml/">&lt;p&gt;A stemming algorithm attempts to reduce words to their stem. For instance, “swimming” would be reduced to “swim”, and “avocados” would become “avocado”. This is useful in a number of situations, most especially in searching text. This library is a direct port of the Porter English stemming algorithm.
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;It was one of my first OCaml projects. I wrote it back in 2003, when I was still new to the language. I had been spending a lot of time writing C libraries that were being called by Perl scripts for my day job. Perl has, or had, a cumbersome, messy interface to C that made such interfaces very difficult to write and maintain.&lt;/p&gt;

&lt;p&gt;When I discovered how easy it was to link C libraries into OCaml, I was overjoyed! This was my first attempt. Before reading further, check out my &lt;a href=&quot;https://github.com/pymander/ocaml-stemmer&quot;&gt;ocaml-stemmer library on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Updating the Code&lt;/h2&gt;

&lt;p&gt;Recently, while overhauling all of my publicly-available code, I decided to update my English-language stemmer for OCaml. It’s not a very large piece of code, but its age really shows. It wouldn’t compile cleanly with the latest version of OCaml. It looks like the code of somebody who hasn’t really grokked functional programming yet. Just look at this.&lt;/p&gt;

&lt;div class=&quot;language-ocaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;rec&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;replace_end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rule_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rule_list&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;hd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tl&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;match_rule&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hd&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;apply_rule&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;replace_end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tl&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ouch, right?&lt;/p&gt;

&lt;p&gt;I decided that the scary code would stand as a good message ((Or maybe I should say a good warning.)) to future functional programmers. For now, I just wanted to get this code to compile and not look messy. That ended up being easy.&lt;/p&gt;

&lt;h2&gt;Finding The Bug&lt;/h2&gt;

&lt;p&gt;Once I got it compiled cleanly, however, I found a bug. Back in 2003, I was big on test-driven development. I wrote tests for lots of code. The OCaml stemmer, it turns out, has been broken for quite a while. It doesn’t handle words with apostrophes correctly!&lt;/p&gt;

&lt;p&gt;I thought that fixing the bug it would be a challenge. However, I quickly I discovered in the OCaml manual that the &lt;code&gt;or&lt;/code&gt; operator was deprecated, and that &lt;code&gt;||&lt;/code&gt; should be used instead. Embarrassingly, the &lt;code&gt;or&lt;/code&gt; operator was deprecated back in 2002. That never should have been in the code! You can view the &lt;a href=&quot;https://github.com/pymander/ocaml-stemmer/commit/40cb816c4d97eea0d51de0f66533c09011f6cbd0&quot; target=&quot;_blank&quot;&gt;commit which fixed the bug here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;My Stemmer Library is Now on OPAM&lt;/h2&gt;

&lt;p&gt;This is my second library on &lt;a href=&quot;http://opam.ocaml.org/&quot; target=&quot;_blank&quot;&gt;OPAM&lt;/a&gt;, including my &lt;a href=&quot;http://arnesonium.com/2014/12/camlprime-now-on-opam/&quot; title=&quot;Camlprime Now on OPAM&quot; target=&quot;_blank&quot;&gt;prime number library&lt;/a&gt;. You can &lt;a href=&quot;http://opam.ocaml.org/packages/stemmer/stemmer.0.2/&quot; target=&quot;_blank&quot;&gt;view it on OPAM here&lt;/a&gt;.&lt;/p&gt;</content>
      </entry>
    
      <entry>
        
        <title>Camlprime Now on OPAM</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/12/camlprime-now-on-opam/" rel="alternate" type="text/html" title="Camlprime Now on OPAM" />
        <updated>2014-12-02T22:19:09+00:00</updated>
        <id>https://arnesonium.com/2014/12/camlprime-now-on-opam</id>
          <category term="math" />
        
          <category term="ocaml" />
        
          <category term="opam" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2014/12/camlprime-now-on-opam/">&lt;p&gt;My first &lt;a href=&quot;http://opam.ocaml.org/&quot; target=&quot;_blank&quot;&gt;OCaml Package Manager (OPAM)&lt;/a&gt; submission has just been accepted. You can now find &lt;a href=&quot;http://arnesonium.com/2014/11/prime-number-library-for-ocaml/&quot; title=&quot;Prime Number Library for OCaml&quot;&gt;Camlprime, a prime number library&lt;/a&gt;, on &lt;a href=&quot;http://opam.ocaml.org/packages/camlprime/camlprime.0.5/&quot; target=&quot;_blank&quot;&gt;OPAM here&lt;/a&gt;.&lt;/p&gt;</content>
      </entry>
    
      <entry>
        
        <title>Learning a New Programming Language</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/11/learning-a-new-programming-language/" rel="alternate" type="text/html" title="Learning a New Programming Language" />
        <updated>2014-11-18T20:21:15+00:00</updated>
        <id>https://arnesonium.com/2014/11/learning-a-new-programming-language</id>
          <category term="ocaml" />
        <content type="html" xml:base="https://arnesonium.com/2014/11/learning-a-new-programming-language/">&lt;p&gt;It’s really hard the first few times. There are many moments of frustration. But in the end, it’s rewarding and you learn interesting things.&lt;/p&gt;

&lt;p&gt;https://twitter.com/pymander/status/533400933548298240&lt;/p&gt;</content>
      </entry>
    
      <entry>
        
        <title>Prime Number Library for OCaml</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/11/prime-number-library-for-ocaml/" rel="alternate" type="text/html" title="Prime Number Library for OCaml" />
        <updated>2014-11-13T17:08:39+00:00</updated>
        <id>https://arnesonium.com/2014/11/prime-number-library-for-ocaml</id>
          <category term="math" />
        
          <category term="ocaml" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2014/11/prime-number-library-for-ocaml/">&lt;p&gt;A couple of weeks ago, I cleaned up my prime number library for &lt;a href=&quot;https://ocaml.org/&quot;&gt;OCaml&lt;/a&gt;. This library has a number of primality-testing methods in it, but my favorite is the &lt;a href=&quot;http://jeremykun.com/2013/06/16/miller-rabin-primality-test/&quot;&gt;Miller-Rabin primality test&lt;/a&gt;. It’s fast and rather accurate.
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;If you’d like to take a look at the library, please check out the &lt;a href=&quot;https://github.com/pymander/camlprime&quot;&gt;camlprime GitHub page&lt;/a&gt;. The library is pretty easy to use. If you download and compile the library, you’ll end up with a toplevel that you can play with.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;test.ml&lt;/code&gt; file has some examples of how to use the primality tests. However, my favorite thing about this library is that it includes a &lt;a href=&quot;https://www.haskell.org/haskellwiki/Lazy_evaluation&quot;&gt;lazy list&lt;/a&gt; implementation of prime numbers. The following example shows how to set up a lazy list of prime numbers proved using the MR algorithm in the toplevel.&lt;/p&gt;

&lt;div class=&quot;language-ocaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;open&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Num&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;make&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;miller_rabin&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_of_int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;LazyList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;LazyList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;503&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lazy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nth&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4363&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The library is pretty fast, even for really large numbers. I’ve tested it on 300-digit prime numbers, and I’m sure it will scale to sizes much larger than that.&lt;/p&gt;

&lt;p&gt;Any thoughts or improvements? Let me know in the comments.&lt;/p&gt;</content>
      </entry>
    
</feed>
