<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/default.xsl"?>
<fr:tree xmlns:fr="http://www.forester-notes.org" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" root="false" base-url="/">
  <fr:frontmatter>
    <fr:authors />
    <fr:uri>https://patrick.sirref.org/part-ii-geocaml/</fr:uri>
    <fr:display-uri>part-ii-geocaml</fr:display-uri>
    <fr:route>/part-ii-geocaml/</fr:route>
    <fr:title text="Effective Geospatial Code in OCaml">Effective Geospatial Code in OCaml</fr:title>
  </fr:frontmatter>
  <fr:mainmatter>
    <html:p>This project is co-supervised with <fr:link href="/mdales/" title="Michael W. Dales" uri="https://patrick.sirref.org/mdales/" display-uri="mdales" type="local">Michael Dales</fr:link>.</html:p>
    <html:blockquote>
      <html:p>Geospatial processing is critical in environmental science and is used in a range of environmental scenarios, both in areas of carbon accounting like digital Monitoring, Reporting and Verification in Reforestation Carbon Removal, and also biodiversity analysis like calculating worldwide extinction rates.</html:p>
      <html:p><![CDATA[However there are problems with the current state of affairs, Python is one of the most popular data science libraries, and when doing geospatial data science with Python you use the GDAL geospatial data library. This workflow is not ideal [2]. For environmental scientists, interacting with the geospatial data in the imperative way that Python requires can be very difficult, and it is also not designed for the scale of computation needed for large geospatial projects. Furthermore, Python’s dynamic type system means that tricky type errors due to heterogeneity of data points can go unchecked. GDAL also only allows synchronous IO for loading GeoTIFF files, which can hurt performance.]]></html:p>
      <html:p>I will write a non-blocking library for reading GeoTIFF files in OCaml (built on top of the WIP OCaml-TIFF library1 written by one of my supervisors, Patrick Ferris). I will then use OCaml to write an embedded Domain Specific Language (eDSL) which will be used to interact with geospatial data in a declarative way.</html:p>
    </html:blockquote>
  </fr:mainmatter>
  <fr:backmatter>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="References">References</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Context">Context</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:date>
              <fr:year>2024</fr:year>
              <fr:month>9</fr:month>
              <fr:day>10</fr:day>
            </fr:date>
            <fr:uri>https://patrick.sirref.org/part-ii-2024/</fr:uri>
            <fr:display-uri>part-ii-2024</fr:display-uri>
            <fr:route>/part-ii-2024/</fr:route>
            <fr:title text="Part II Students 2024">Part II Students 2024</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>In the final year of the <fr:link href="/ucam/" title="University of Cambridge" uri="https://patrick.sirref.org/ucam/" display-uri="ucam" type="local">Cambridge</fr:link> undergraduate degree in computer science, students undertake a coding project with an accompanying dissertation.</html:p>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:uri>https://patrick.sirref.org/part-ii-hazel/</fr:uri>
                <fr:display-uri>part-ii-hazel</fr:display-uri>
                <fr:route>/part-ii-hazel/</fr:route>
                <fr:title text="Type Error Debugging in Hazel">Type Error Debugging in Hazel</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:blockquote>
                  <html:p>This project will add some features to the <fr:link href="/hazel/" title="Hazel" uri="https://patrick.sirref.org/hazel/" display-uri="hazel" type="local">Hazel</fr:link> language. <fr:link href="/hazel/" title="Hazel" uri="https://patrick.sirref.org/hazel/" display-uri="hazel" type="local">Hazel</fr:link> is a functional research language that makes use of gradual types to support unusual features such as: holes (code place-holders) to give type meaning to incomplete programs. Importantly for this project, all Hazel programs, even ill-typed or incomplete programs, are evaluable. This allows dynamic reasoning about ill-typed programs via evaluation traces with the potential to improve the user’s understanding of why ill-typed programs go wrong.</html:p>
                  <html:p>This project aims to exploit further this potential by providing some extra features to both: aid with finding values/inputs that demonstrate why type-errors were found (type-error witnesses) and linking the evaluation traces back to source code.</html:p>
                </html:blockquote>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:uri>https://patrick.sirref.org/part-ii-udsl/</fr:uri>
                <fr:display-uri>part-ii-udsl</fr:display-uri>
                <fr:route>/part-ii-udsl/</fr:route>
                <fr:title text="A Universal Data Access DSL">A Universal Data Access DSL</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:blockquote>
                  <html:p>The design and implementation of a jq-like EDSL allowing programmers to abstract away the format in which data is stored (YAML, EXIF metadata etc.) and the file system being used – e.g. <html:code><![CDATA[open("a/b/[c,d]")]]></html:code> could mean "fields c, d in YAML file b of ZIP file a", or it could mean "fields b.c, b.d in JSON file a". My project would statically examine the filesystem to decide which case we're in, giving data scientists an easy way to declare the shape of the data they depend on. Success criteria include projection (correctly reading the data based on the file type), subtyping (e.g. JSON-LD is a child of JSON) and perhaps some compiler optimisations related to parsing (e.g. only loading a JSON library if the file is actually JSON).</html:p>
                </html:blockquote>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:uri>https://patrick.sirref.org/part-ii-paraeff/</fr:uri>
                <fr:display-uri>part-ii-paraeff</fr:display-uri>
                <fr:route>/part-ii-paraeff/</fr:route>
                <fr:title text="Implementing Parallel Algebraic Effect Handlers in OCaml">Implementing Parallel Algebraic Effect Handlers in OCaml</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:blockquote>
                  <html:p>Algebraic effects are becoming increasingly common, but it can be difficult to use them in parallel computations. Xie et al. (2024) present a new structure for effect handlers which allows parallel subcomputations to perform effects independently without synchronisation. I plan to implement the traverse handler in OCaml 5 and evaluate its performance against equivalent programs which do not use effects using a variety of benchmark programs. As extensions, I will devise similar handlers for other types of parallelism, possibly including a more general form which works for many types simultaneously, and investigate how to improve its real-world performance.</html:p>
                </html:blockquote>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors />
                <fr:uri>https://patrick.sirref.org/part-ii-geocaml/</fr:uri>
                <fr:display-uri>part-ii-geocaml</fr:display-uri>
                <fr:route>/part-ii-geocaml/</fr:route>
                <fr:title text="Effective Geospatial Code in OCaml">Effective Geospatial Code in OCaml</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>This project is co-supervised with <fr:link href="/mdales/" title="Michael W. Dales" uri="https://patrick.sirref.org/mdales/" display-uri="mdales" type="local">Michael Dales</fr:link>.</html:p>
                <html:blockquote>
                  <html:p>Geospatial processing is critical in environmental science and is used in a range of environmental scenarios, both in areas of carbon accounting like digital Monitoring, Reporting and Verification in Reforestation Carbon Removal, and also biodiversity analysis like calculating worldwide extinction rates.</html:p>
                  <html:p><![CDATA[However there are problems with the current state of affairs, Python is one of the most popular data science libraries, and when doing geospatial data science with Python you use the GDAL geospatial data library. This workflow is not ideal [2]. For environmental scientists, interacting with the geospatial data in the imperative way that Python requires can be very difficult, and it is also not designed for the scale of computation needed for large geospatial projects. Furthermore, Python’s dynamic type system means that tricky type errors due to heterogeneity of data points can go unchecked. GDAL also only allows synchronous IO for loading GeoTIFF files, which can hurt performance.]]></html:p>
                  <html:p>I will write a non-blocking library for reading GeoTIFF files in OCaml (built on top of the WIP OCaml-TIFF library1 written by one of my supervisors, Patrick Ferris). I will then use OCaml to write an embedded Domain Specific Language (eDSL) which will be used to interact with geospatial data in a declarative way.</html:p>
                </html:blockquote>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Backlinks">Backlinks</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors>
              <fr:author>
                <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
              </fr:author>
            </fr:authors>
            <fr:date>
              <fr:year>2026</fr:year>
              <fr:month>9</fr:month>
              <fr:day>30</fr:day>
            </fr:date>
            <fr:uri>https://patrick.sirref.org/weekly-2026-w39/</fr:uri>
            <fr:display-uri>weekly-2026-w39</fr:display-uri>
            <fr:route>/weekly-2026-w39/</fr:route>
            <fr:title text="Weekly 2026 w39">Weekly 2026 w39</fr:title>
          </fr:frontmatter>
          <fr:mainmatter>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors>
                  <fr:author>
                    <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
                  </fr:author>
                </fr:authors>
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>30</fr:day>
                </fr:date>
                <fr:title text="Shells">Shells</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>Work on the <html:code>msh</html:code> paper continued this week. One interesting result (for an appendix) was seeing what were the most commonly used commands in the Dockerfile dataset:</html:p>
                <html:div style="text-align: center;">
<html:img height="300px" src="/bafkrmiaymigdysonokzjdw4r6yja7ntc3wq62dvkegurdlaxaalrqbo4b4.png" />
</html:div>
                <html:p>Which again, leads to some notion of <html:em>overkill</html:em> in terms of using a shell as the means to create container images when all we do is move some files around and install packages! I'm wondering if we're missing a real opportunity to streamline this process via something like <fr:link href="/pkg-calc2026gibb/" title="Package Managers à la Carte" uri="https://patrick.sirref.org/pkg-calc2026gibb/" display-uri="pkg-calc2026gibb" type="local">the package calculus</fr:link> -- a package manager-agnostic means for declaring your dependencies.</html:p>
                <html:p>Embed that as a programmable notion in your container image language alongside a container image-aware HTTP GET tool (to replace a vast majority of <html:code>curl</html:code> calls) and a handful of busybox commands, and you are left with (nearly) the raw shell only being used for the long tail of domain-specific things (e.g. invoking a build system).</html:p>
                <fr:tree show-metadata="false" numbered="false">
                  <fr:frontmatter>
                    <fr:authors>
                      <fr:author>
                        <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
                      </fr:author>
                    </fr:authors>
                    <fr:date>
                      <fr:year>2026</fr:year>
                      <fr:month>9</fr:month>
                      <fr:day>30</fr:day>
                    </fr:date>
                    <fr:title text="Joy in old documents">Joy in old documents</fr:title>
                  </fr:frontmatter>
                  <fr:mainmatter>
                    <html:p>I'll talk about the joy I found in reading some historical bits and bobs tracking down information about shells, containers and operating systems more generally.</html:p>
                    <html:p>Part of this archaeological effort was trying to find when <html:code>CHROOT</html:code> was introduced into UNIX. Various online tools, including AI summaries, point to <fr:link href="/unix7thmanual/" title="{UNIX} Programmer's Manual, Seventh Edition" uri="https://patrick.sirref.org/unix7thmanual/" display-uri="unix7thmanual" type="local">UNIX v7</fr:link> but the system call is not obviously defined there. A bit more digging reveals it is listed under <html:code>CHDIR(2)</html:code> and not on its own.</html:p>
                    <html:p>Anyway, flicking through the manual was somewhat of a joy. The preface reads:</html:p>
                    <html:blockquote>
                      <html:p>This new form of the Seventh Edition manual attests to the gratifying popularity of the UNIX Operating System. Delivered with no support and with an amateurishly published manual, this elegant and productive system has nevertheless earned worldwide respect, sometimes bordering on adulation...</html:p>
                      <html:p>Thousands of users today work from faint reproductions of reproductions of the original manual, whose ragged pages dangle and slide out of beat-up ring binders...</html:p>
                    </html:blockquote>
                    <html:p>This bordering-on-poetic prose reminds me of some passages written for the MULTICS manual too (which I have <fr:link href="/pouzin-shell/" title="Metashells › Louis Pouzin's &quot;SHELL&quot; " uri="https://patrick.sirref.org/pouzin-shell/" display-uri="pouzin-shell" type="local">talked about before</fr:link>).</html:p>
                    <html:p>All to say, I'm often thinking about the importance of writing these days and injecting some personality into it.</html:p>
                  </fr:mainmatter>
                </fr:tree>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors>
                  <fr:author>
                    <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
                  </fr:author>
                </fr:authors>
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>30</fr:day>
                </fr:date>
                <fr:title text="Part II Discussions">Part II Discussions</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>I am hopefully going to supervise a <fr:link href="/part-ii/" title="Part II Projects" uri="https://patrick.sirref.org/part-ii/" display-uri="part-ii" type="local">part II project</fr:link> this year either on a fun ergonomic frontend to eBPF programs or a new spin on the <fr:link href="/part-ii-geocaml/" title="Effective Geospatial Code in OCaml" uri="https://patrick.sirref.org/part-ii-geocaml/" display-uri="part-ii-geocaml" type="local">geospatial DSL</fr:link>. More to follow once things are finalised.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors>
                  <fr:author>
                    <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
                  </fr:author>
                </fr:authors>
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>30</fr:day>
                </fr:date>
                <fr:title text="Upstreaming Forester Pretty-printer">Upstreaming Forester Pretty-printer</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p>I finally got around to upstreaming the <fr:link href="/forester/" title="Forester" uri="https://patrick.sirref.org/forester/" display-uri="forester" type="local">Forester</fr:link> pretty-printing API I have been using in <fr:link href="/graft/" title="Graft" uri="https://patrick.sirref.org/graft/" display-uri="graft" type="local">Graft</fr:link>. This allows you to print, hopefully, syntactically correct <fr:link href="/forester/" title="Forester" uri="https://patrick.sirref.org/forester/" display-uri="forester" type="local">Forester</fr:link> code directly from the AST (a <html:code>Code.t</html:code> in forester parlance).</html:p>
                <html:p>Happily, <fr:link href="https://tangled.org/jonmsterling.com/ocaml-forester/pulls/1/round/0" type="external">this all took place on tangled</fr:link>. It will be nice to keep this updated alongside <fr:link href="/forester/" title="Forester" uri="https://patrick.sirref.org/forester/" display-uri="forester" type="local">Forester</fr:link> and point <fr:link href="/graft/" title="Graft" uri="https://patrick.sirref.org/graft/" display-uri="graft" type="local">Graft</fr:link> to it. It feels like many people are moving away from a community-oriented model of software development, instead building a hybrid bazaarian cathedral monorepo powered by AI. I'm not here to really say what is right and what is wrong, but it seems to me that the sense of community is fragmenting and undue stress is being placed on many maintainers who no longer enjoy their job.</html:p>
              </fr:mainmatter>
            </fr:tree>
            <fr:tree show-metadata="false" numbered="false">
              <fr:frontmatter>
                <fr:authors>
                  <fr:author>
                    <fr:link href="https://patrick.sirref.org/Patrick Ferris/" type="external">Patrick Ferris</fr:link>
                  </fr:author>
                </fr:authors>
                <fr:date>
                  <fr:year>2026</fr:year>
                  <fr:month>9</fr:month>
                  <fr:day>30</fr:day>
                </fr:date>
                <fr:uri>https://patrick.sirref.org/ppx_deriving_yamlx-release/</fr:uri>
                <fr:display-uri>ppx_deriving_yamlx-release</fr:display-uri>
                <fr:route>/ppx_deriving_yamlx-release/</fr:route>
                <fr:title text="New release of ppx_deriving_">New release of ppx_deriving_</fr:title>
              </fr:frontmatter>
              <fr:mainmatter>
                <html:p><fr:link href="https://github.com/patricoferris/ppx_deriving_yaml/pull/63" type="external">Raphael has proposed a new yamlx backend</fr:link> for <html:code>ppx_deriving_yaml</html:code>. It seems <fr:link href="https://github.com/ahrefs/ppx_deriving_yaml/tree/yamlx" type="external">Ahrefs have been using his patch</fr:link>. I rejigged that PR to parameterise <html:code>ppx_deriving_yaml</html:code> over a <fr:link href="https://github.com/patricoferris/ppx_deriving_yaml/blob/d7a78e8609a6bccf27b66b49aa8dcc2ff76d68ed/src/common/ppx_deriving_yaml_types.ml" type="external">small set of constructors</fr:link> and <fr:link href="https://github.com/patricoferris/ppx_deriving_yaml/blob/d7a78e8609a6bccf27b66b49aa8dcc2ff76d68ed/src/common/ppx_deriving_yaml_common.mli#L18-L27" type="external">patterns</fr:link> so that the core codec logic could be reused.</html:p>
                <html:p>I am fairly pleased with this abstraction. It allows any data format that supports objects and list to reuse the codec. For example, it would be trivial now to add a <fr:link href="https://ocaml.org/p/cbor/latest/doc/cbor/CBOR/Simple/index.html" type="external">ppx_deriving_cbor</fr:link>.</html:p>
              </fr:mainmatter>
            </fr:tree>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Related">Related</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://patrick.sirref.org/mdales/</fr:uri>
            <fr:display-uri>mdales</fr:display-uri>
            <fr:route>/mdales/</fr:route>
            <fr:title text="Michael W. Dales">Michael W. Dales</fr:title>
            <fr:meta name="external">https://digitalflapjack.com</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter />
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Contributions">Contributions</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
  </fr:backmatter>
</fr:tree>
