<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Dominic Orchard — Blog</title>
  <link href="https://dorchard.github.io/feed.xml" rel="self"/>
  <link href="https://dorchard.github.io/blog.html"/>
  <id>https://dorchard.github.io/feed.xml</id>
  <updated>2026-11-19T13:45:03+00:00</updated>
  <author><name>Dominic Orchard</name></author>
  
  
  <entry>
    <title>Writing is thinking, and programming is thinking too</title>
    <link href="https://dorchard.github.io/blog/2026/11/18/programming-as-thinking/"/>
    <id>https://dorchard.github.io/blog/2026/11/18/programming-as-thinking/</id>
    <updated>2026-11-18T00:00:00+00:00</updated>
    <category term="programming"/>
    <category term="writing"/>
    <category term="llms"/>
    <summary>If writing is thinking, then so is programming (and so is making slides). Over-reliance on AI can therefore rob us of the chance to think.</summary>
    <content type="html">&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dorchard.github.io/assets/blog-thinking.png&quot; alt=&quot;A laptop and notebook at night&quot; class=&quot;post-banner&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;post-caption&quot;&gt;The ‘bureau’ where I did lots of thinking as a postdoc (Cambridge, circa 2014).
Based on a photo taken on an old smartphone, sharpened up by GPT-6.&lt;/p&gt;

&lt;p class=&quot;post-credit&quot;&gt;Image by Dominic Orchard, licensed under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;A colleague recently pointed me at this lovely article in the
Economist, titled “&lt;strong&gt;AI often makes writing worse. (Even if it makes it
better)&lt;/strong&gt;” &lt;a class=&quot;cite&quot; id=&quot;cite-1&quot; href=&quot;#ref-1&quot;&gt;[1]&lt;/a&gt;. The article includes the following argument:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Real writing is not writing at all. It is thinking; specifically it
is thinking: “What do I think?”&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;The Economist&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It goes on to quote Prof. Emma Smith (University of Oxford): “&lt;em&gt;Often, ‘you only really know what you think by writing it’&lt;/em&gt;”. This reminded me of two other quotes which I have pinned in the
introductory page of a “team” repository that I share with all my students and postdocs:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you’re thinking without writing, you only think you’re
thinking. […] Everyone thinks they think. If you don’t write down
your thoughts, you are fooling yourself.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Leslie Lamport, creator of LaTeX&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Writing is Nature’s way of showing you how sloppy your thinking is.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Dick Guindon, cartoonist&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In all of these quotes, people are tapping into the idea that many
people have discovered and discussed &lt;a class=&quot;cite&quot; id=&quot;cite-3&quot; href=&quot;#ref-3&quot;&gt;[3]&lt;/a&gt;&lt;a class=&quot;cite&quot; id=&quot;cite-4&quot; href=&quot;#ref-4&quot;&gt;[4]&lt;/a&gt;&lt;a class=&quot;cite&quot; id=&quot;cite-5&quot; href=&quot;#ref-5&quot;&gt;[5]&lt;/a&gt;&lt;a class=&quot;cite&quot; id=&quot;cite-6&quot; href=&quot;#ref-6&quot;&gt;[6]&lt;/a&gt;, that the act of writing gives
you a chance to really think about an idea, problem, or argument.
Writing helps you generate new ideas, deepens your exploration of a
problem, and helps you understand how to evaluate it.&lt;/p&gt;

&lt;p&gt;This aligns with the advice Simon Peyton Jones gives, that
as soon as you have an idea, you should start writing the paper about it &lt;a class=&quot;cite&quot; id=&quot;cite-2&quot; href=&quot;#ref-2&quot;&gt;[2]&lt;/a&gt;.
Why? Because it forces you to confront what you don’t yet understand and
what evidence is needed. Writing opens up a way to have a dialogue
with others who can critique and collaborate on the idea.&lt;/p&gt;

&lt;p&gt;Going back to the Economist article, their point is that if we give
writing over to AI we lose that opportunity to think for ourselves. I
know some find it daunting, but I relish starting with an
empty page and a fresh idea because I know that is where the action
happens! Getting it down on paper helps my brain to think it through rather
than “fooling myself” (Lamport) that I understand the idea well
enough. And if I get stuck, I can always switch things up and try
some different writing strategies. (I have written &lt;a href=&quot;https://dorchard.github.io/advice/writing-strategies.html&quot;&gt;a whole list of
them&lt;/a&gt;, to help me and my students;
useful, I hope, when hitting writer’s block!)&lt;/p&gt;

&lt;p&gt;If writing is thinking, then I believe the same also applies to &lt;em&gt;programming&lt;/em&gt;.
I do not think this will be a controversial point (at least not
amongst my computer science colleagues), but in the current
‘AI summer’ this idea seems to be getting lost, and may be missed
by those without a background in programming.&lt;/p&gt;

&lt;p class=&quot;callout&quot;&gt;Programming is thinking&lt;/p&gt;

&lt;p&gt;We are in a world
where AI agents are writing large amounts of code, and people are wondering
whether software engineering is a dying art with code increasingly
becoming just an opaque box we do not need to, or indeed cannot reasonably, inspect.
But just as writing is thinking, &lt;em&gt;programming is thinking&lt;/em&gt; too! At least,
it can be. Many times I’ve grappled with a problem
or idea, from a variety of domains, by writing code about it.
I often tell undergraduate students to
‘implement their mathematics’ as a way of helping them to get a better
intuitive grasp of the ideas. By programming some concept or theory, the student gains a deeper appreciation for something abstract. A germane quote:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;People have said you don’t understand something until you’ve taught
it in a class. The truth is you don’t really understand something
until you’ve taught it to a computer, until you’ve been able to
program it.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;George Forsythe&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;span style=&quot;color:#888&quot;&gt;(I couldn’t find the origin of the quote, but it is mentioned
in a &lt;em&gt;Communications of the ACM&lt;/em&gt; interview with Donald Knuth which touches on similar ideas &lt;a class=&quot;cite&quot; id=&quot;cite-7&quot; href=&quot;#ref-7&quot;&gt;[7]&lt;/a&gt;.)&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The point is that computers (in their traditional way of working)
are very stupid. To ‘explain an idea to them’
you have to spell things out, in code, in considerable detail.
But doing so makes sure that you yourself understand the idea. And then
you have an object ‘in your hand’ which you can inspect and probe, by running
it with particular inputs or applying other kinds of analysis. If we just automatically
turn to an LLM to do our programming work, we miss out on the opportunity
to actually explore a problem or an idea. Not all programming is like
this, but certainly some is. This fits into the broader notion of ‘computational thinking’ &lt;a class=&quot;cite&quot; id=&quot;cite-8&quot; href=&quot;#ref-8&quot;&gt;[8]&lt;/a&gt; which was big about 10–15 years ago,
where we leverage ideas from computing as analytical techniques to
help solve problems and design systems.&lt;/p&gt;

&lt;p&gt;So writing is thinking, and programming is thinking,
and I think that a similar argument could be made for other kinds of
‘content production’. Perhaps a bit more of a parochial example,
but for similar reasoning, I propose that:&lt;/p&gt;

&lt;p class=&quot;callout&quot;&gt;Writing slides is thinking&lt;/p&gt;

&lt;p&gt;I personally find writing slides for talks and lectures to be a hard
slog, and it is a significant component of my job. But the process of
writing those slides (which can take me as long as a day for a one-hour
talk or lecture) gives me a chance to think through what key messages
I want to get across, how I want to say them, in what order,
what story I want to tell, and what examples to include. The deep work
of staring at blank slides, moving bits of text and pictures around,
is a time when my brain is preparing all the groundwork for the
actual spoken, embodied delivery. I’ve sat through a lot of obviously (or explicitly
stated) LLM-generated slide decks recently and I just cannot imagine
being able to do a good talk myself in this way;&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; maybe others can do it, but I need that time, that sometimes
painful time, to sit soaking in the material trying to drag out a
coherent story through it. For research talks, this almost always
helps me better understand, analyse, and evaluate the key ideas in the
research itself.&lt;/p&gt;

&lt;p&gt;Passing large parts of these tasks (writing, programming, slide
making) to AI then robs us of the chance to think. I don’t think this
necessarily means there is no way to use LLMs effectively in the
process of programming, but I think we need to make careful choices
about what we are willing to &lt;em&gt;not&lt;/em&gt; think about.&lt;/p&gt;

&lt;p&gt;So, writing is thinking, and programming is thinking, and preparing
slide decks is thinking.&lt;/p&gt;

&lt;p&gt;Let’s keep thinking!&lt;/p&gt;

&lt;p style=&quot;color:grey&quot;&gt;(No AI was used in the writing of this blog post).&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ol class=&quot;references&quot;&gt;
  &lt;li id=&quot;ref-1&quot;&gt;The Economist. &lt;a href=&quot;https://www.economist.com/britain/2026/09/24/ai-often-makes-writing-worse-even-if-it-makes-it-better&quot;&gt;AI often makes writing worse. (Even if it makes it better)&lt;/a&gt;. &lt;em&gt;The Economist&lt;/em&gt;, September 2026. &lt;a href=&quot;#cite-1&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-2&quot;&gt;Simon Peyton Jones. &lt;a href=&quot;https://www.robots.ox.ac.uk/~phst/PhD/writing-a-paper-slides.pdf&quot;&gt;How to write a great research paper&lt;/a&gt;. Slides. &lt;a href=&quot;#cite-2&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-3&quot;&gt;Keith Oatley and Maja Djikic. &lt;a href=&quot;https://doi.org/10.1037/1089-2680.12.1.9&quot;&gt;Writing as Thinking&lt;/a&gt;. &lt;em&gt;Review of General Psychology&lt;/em&gt;, 12(1), 9–27, 2008. &lt;a href=&quot;#cite-3&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-4&quot;&gt;Richard Menary. &lt;a href=&quot;https://doi.org/10.1016/j.langsci.2007.01.005&quot;&gt;Writing as thinking&lt;/a&gt;. &lt;em&gt;Language Sciences&lt;/em&gt;, 29(5), 621–632, 2007. &lt;a href=&quot;#cite-4&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-5&quot;&gt;Hans Sluga. &lt;a href=&quot;https://www.proquest.com/openview/1e72778b1cd1f2c9ff4a9f4743c1356c/1&quot;&gt;Thinking as Writing&lt;/a&gt;. &lt;em&gt;Grazer Philosophische Studien&lt;/em&gt;, 33, 115, 1989. &lt;a href=&quot;#cite-5&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-6&quot;&gt;Mary S. Lawrence. &lt;em&gt;Writing as a Thinking Process&lt;/em&gt;. University of Michigan Press, 1996. (&lt;a href=&quot;https://tesl-ej.org/wordpress/issues/volume2/ej08/ej08r3/&quot;&gt;Review by Robert Retherford&lt;/a&gt;, &lt;em&gt;TESL-EJ&lt;/em&gt;, 2(4), 1997.) &lt;a href=&quot;#cite-6&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-7&quot;&gt;Donald Knuth. &lt;a href=&quot;https://cacm.acm.org/opinion/interview-donald-knuth-a-lifes-work-interrupted/&quot;&gt;Interview: Donald Knuth: A Life&apos;s Work Interrupted&lt;/a&gt;. &lt;em&gt;Communications of the ACM&lt;/em&gt;, 51(8), 31–35, 2008. &lt;a href=&quot;#cite-7&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-8&quot;&gt;Jeannette M. Wing. &lt;a href=&quot;https://doi.org/10.1145/1118178.1118215&quot;&gt;Computational thinking&lt;/a&gt;. &lt;em&gt;Communications of the ACM&lt;/em&gt;, 49(3), 33–35, 2006. &lt;a href=&quot;#cite-8&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is similar to how I find it very hard to reuse someone else’s slides for teaching; I need the time to think about how I’m going to explain it, otherwise I will not be able to communicate the ideas as effectively. Relatedly, I saw a talk by a senior academic who admitted the slides were AI-assisted; partway into one slide they said “I don’t like this slide, AI has made it too complicated” and then just skipped it! &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
  </entry>
  
  <entry>
    <title>On the Role and Design of Software Interfaces in the LLM context</title>
    <link href="https://dorchard.github.io/blog/2026/11/03/on-interfaces-and-llms/"/>
    <id>https://dorchard.github.io/blog/2026/11/03/on-interfaces-and-llms/</id>
    <updated>2026-11-03T00:00:00+00:00</updated>
    <category term="programming"/>
    <category term="science"/>
    <category term="software engineering"/>
    <category term="llms"/>
    <summary>Designing good interfaces for software, both external and internal, is hard. This post considers the potential negative effects of LLMs in this context and discusses good interface design ideas.</summary>
    <content type="html">&lt;p&gt;&lt;img src=&quot;https://dorchard.github.io/assets/interfaces-pic.png&quot; alt=&quot;An abstract image of code showing some python interfaces with types&quot; class=&quot;post-banner&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;post-caption&quot;&gt;Good interfaces communicate intent and ideas.&lt;/p&gt;

&lt;p class=&quot;post-credit&quot;&gt;Image by Dominic Orchard, licensed under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Designing good interfaces for software, both external and internal, is
hard.  By ‘external’, I mean the mechanisms by which users will
compile/build/link (if needed) and run the software, how they will
interact with it, and how it will interoperate with other software
systems.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; By ‘internal’, I
mean the software architecture, and the programming interfaces and
abstractions which delineate subcomponents of the code to enable
reuse, de-duplication, understanding, and reasoning.&lt;/p&gt;

&lt;p&gt;A risk I fear with significant LLM use for software
engineering is that badly designed interfaces are reinforced; rather
than seeking more illuminating interface designs, the LLM papers
over the cracks, burning through extra energy to find, and re-find,
ways to achieve a stated goal. The result may be both inefficient in
its generation (‘tokens burned’) and inefficient in its final generated
form, e.g., in terms of computational cost or maintenance cost
(code bloat and obfuscation). Good interfaces instead aid
understanding. They expose the essential concepts behind a piece of
software in ways that stimulate new ideas and approaches, help avoid
misunderstandings and bugs, and reduce effort in the code development
process.&lt;/p&gt;

&lt;p&gt;All such benefits can be harvested by both humans &lt;em&gt;and&lt;/em&gt;
computers, and not just LLMs. Analytical processes like static
analysis tools and compilers can also benefit from abstractions that
expose more information about a program and provide increased
modularisation, which helps with scalability.&lt;/p&gt;

&lt;p&gt;The role of documentation is also important here and has a non-trivial
interaction with software design. Good documentation can lessen some
of the worst effects of design weaknesses, and poor documentation can
increase the friction and effort in making use of even a good
interface. Intuitively, documentation should have a role to play in improved
LLM performance as well. One study looking at the relationship
between documentation and the ability to generate
unit tests did not yield a strong correlation &lt;a class=&quot;cite&quot; id=&quot;cite-1&quot; href=&quot;#ref-1&quot;&gt;[1]&lt;/a&gt; but later studies (in the context of Java)
 showed a considerable improvement in the ability to generate test oracles when documentation was included
&lt;a class=&quot;cite&quot; id=&quot;cite-2&quot; href=&quot;#ref-2&quot;&gt;[2]&lt;/a&gt;.
I do not have time to dig
deeper into the evidence here, but my experience, and those of some of my
colleagues, is that having good design documentation seems to benefit
LLMs (improved quality and reduced time to solution).&lt;/p&gt;

&lt;p&gt;In the context of external interfaces, my experience has been that
LLMs can be very useful for working out how to get complex software
stacks working and building, e.g., running scientific models that
require a diversity of libraries, additional software, and HPC
environments, with complex non-standard configuration systems. This
appears to be a big win, offloading some human effort to the machine,
at some additional energy cost downstream. In the computational
science context, where a lot of time can be spent getting the models
of other groups running, I think there can be a considerable productivity
improvement here. Removing the
barriers around the build processes and external interfaces 
means that more models can be explored and investigated from others’ work.&lt;/p&gt;

&lt;p&gt;However, at the internal, software level, I’ve found that LLMs
(including at the frontier as of writing in Autumn 2026) by default steer
towards writing more and more code rather than trying to find good
abstractions and interfaces. I usually find things work better if I
design the architecture and interfaces largely myself, do the deep
thinking about the design concepts and ideas, and then have the LLM
assist in writing the ‘inside’ code, rather than the other way around.&lt;/p&gt;

&lt;p&gt;One could compare this with the observation that LLMs do not invent
new ‘mathematical objects’ (i.e., abstractions) in the way that
mathematicians do.
Some aspects of this tension arise in the recent discussions around AI
autoformalisation of mathematics in interactive theorem provers.
In a joint blog post &lt;a class=&quot;cite&quot; id=&quot;cite-3&quot; href=&quot;#ref-3&quot;&gt;[3]&lt;/a&gt;, Jeremy Avigad, Kevin Buzzard, Johan Commelin, Rémy
Degenne, Kim Morrison, Oliver Nash and Adam Topaz, posit that:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Knowledge isn’t worth having until it contributes to our
understanding; the value of a formalization comes from our ability to
use and interact with the data.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Jeremy Avigad et al.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I believe the interface provided by
any proof code seriously affects our ability to use and interact with
it, and thus to grow our understanding.  They go on to say:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Good formal
libraries will enable the positive vision we have for the future of
mathematical research.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Jeremy Avigad et al.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The “good” here is exactly those interface
designs that enable human understanding and flexible reuse of
existing ideas, whether proofs or code–which are really &lt;a href=&quot;https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence&quot;&gt;the same thing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unmesh Joshi and Martin Fowler talked about issues around software
design and LLMs in a curated conversation in 2025: &lt;a href=&quot;https://martinfowler.com/articles/convo-llm-abstractions.html&quot;&gt;LLMs and Building
Abstractions&lt;/a&gt;.
There is a lot of great discussion here which I largely agree with.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; The conversation
orbits around ideas of how the programming process shapes the software
in an iterative process that is hard to achieve with an ‘upfront design’.
A quote:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Programming isn’t just typing coding
syntax that computers can understand and execute; it’s shaping a
solution. We slice the problem into focused pieces, bind related data
and behaviour together, and—crucially—choose names that expose
intent.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Unmesh Joshi&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This takes us back to good interface design and how
it emerges from the process of writing the
code ourselves, where continued iteration helps us to form ideas
into something coherent and understandable by others. Domain-specific
terminology may shape our interfaces and abstractions explicitly. 
Another quote:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I think of programming as having two deeply interwoven activities.&lt;/p&gt;

  &lt;p&gt;The first of these is Discovering and Stabilizing Abstractions.&lt;/p&gt;

  &lt;p&gt;This is creative in
nature-the part where we explore multiple options, experiment, and
slowly converge on stable abstractions. In this activity, we observe
coding patterns, decide what is common, and identify what might vary
in the future. We then choose language constructs that arrange these
common elements in a way that makes future variation easier.&lt;/p&gt;

  &lt;p&gt;Once abstractions are stable—well-named, well-tested, and
well-understood—we Apply Stable Abstractions to implement new use
cases or variations. In Domain-Driven Design (DDD) terms, this is
where we work with the domain model: a set of named abstractions that
reflect the business domain and carry precise meaning.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Unmesh Joshi&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This points to the key activities in defining our internal software
interfaces. One can imagine trying to explicitly codify this in
the software development process, instigating first a phase of
discovery where one or more programmers or LLMs explores a few different
designs and ideas, followed by a stabilisation process in which consensus
around a single approach is built. The resulting stabilised abstractions
can then give LLMs and humans a stronger set of
building blocks (a ‘vocabulary’) to work with, reducing their
 overall efforts. But getting to this point requires thought and iteration.&lt;/p&gt;

&lt;p&gt;A last germane quote is from Guy Steele’s 1998 OOPLSA keynote &lt;a href=&quot;https://www.youtube.com/watch?v=_ahvzDzKdB0&quot;&gt;“Growing
a language”&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[..] a good programmer in these times does not just write programs. A good programmer builds a working vocabulary. In other words, a good programmer does language design, though not from scratch, but by building on the frame of a base language.&lt;/p&gt;

  &lt;p class=&quot;quote-author&quot;&gt;Guy Steele&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Part of designing the software interfaces in our code is exactly this
process of growing a language: an internal, embedded, domain-specific
language capturing our intent in the code. If we let LLMs do all
of this work without our involvement,
then LLMs will make choices for us that will almost
certainly differ to what comes out of our own iterated thinking.
Simply reviewing the output from LLMs is unlikely to lead to
significant changes in the overall design once code has been written
(something like the effect of a ‘status quo bias’, falling into a low-effort
‘rubber stamping’ behaviour).&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; This is not to say that
we must not use LLMs in this process, but my caution would be in
letting the LLMs make all the design decisions
without the human-in-the-loop to provide their knowledge, context,
and expertise of the problem, and their overall aesthetic and technical
design sense.&lt;/p&gt;

&lt;p&gt;Going back to the original point,
if an LLM does all the work we risk embedding
poor designs which later on impede further work.
By giving serious consideration to software
interfaces, both the internal and external, the end result
is software that overall requires less effort to understand, use, maintain,
 and extend, for both humans and machines.
 For LLMs, more effort equates to more electricity consumed, and
&lt;a href=&quot;https://www.bloomberg.com/news/articles/2026-10-28/us-data-center-buildout-risks-erasing-years-of-climate-progress?accessToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb3VyY2UiOiJTdWJzY3JpYmVyR2lmdGVkQXJ0aWNsZSIsImlhdCI6MTc5MzIxODQ4MywiZXhwIjoxNzkzODIzMjgzLCJhcnRpY2xlSWQiOiJUTk03WTFLSVAzSVAwMCIsImJjb25uZWN0SWQiOiJGM0VENDU5NTZFRjA0QjY5QTI0NTVBNTYxRDkyNkY5NiJ9.vaYGVNos-PgwrFAeFWxa9-gyGHRxRihCe_on05i2B3A&amp;amp;leadSource=article-gifting&quot;&gt;more data centre demand&lt;/a&gt;, the growth of which should be a serious concern for us all.&lt;/p&gt;

&lt;p&gt;Now, how to actually design good interfaces is a huge topic and there
is a lot that could be said here, indeed there are lots of
books on designing software architecture. I’ll leave this topic
for another blog post then. That said, a few thoughts were sloshing around
my head in the preparation of this blog post so I’ll finish with a few of these (non-exhaustive) thoughts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Be intentional about interface design: build in time in the development
process for discovering abstractions and then reviewing/stabilsing abstractions;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;“Make interfaces easy to use correctly and hard to use incorrectly” &lt;a class=&quot;cite&quot; id=&quot;cite-4&quot; href=&quot;#ref-4&quot;&gt;[4]&lt;/a&gt;;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Exploit types if available to encode meaning and then enforce the correct behaviour and
expose incorrect behaviour;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;A good abstraction should be about more than just avoiding duplication &lt;a class=&quot;cite&quot; id=&quot;cite-5&quot; href=&quot;#ref-5&quot;&gt;[5]&lt;/a&gt;;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Choose names and naming schemes that reflect the domain as much as possible to build
up a ‘ubiquitous language’ / vocabulary. &lt;a class=&quot;cite&quot; id=&quot;cite-6&quot; href=&quot;#ref-6&quot;&gt;[6]&lt;/a&gt;;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Write design documentation, including what are the main values, principles, and goals of
the project and its design.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;color:grey&quot;&gt;(No AI was used in the writing of this blog post).&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ol class=&quot;references&quot;&gt;
  &lt;li id=&quot;ref-1&quot;&gt;William Macke and Michael Dean Doyle. &lt;a href=&quot;https://aclanthology.org/2024.findings-naacl.66/&quot;&gt;Testing the effect of code documentation on large language model code understanding&lt;/a&gt;. In &lt;em&gt;Findings of the Association for Computational Linguistics: NAACL 2024&lt;/em&gt;, 2024. &lt;a href=&quot;#cite-1&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-2&quot;&gt;Soneya Binta Hossain, Raygan Taylor and Matthew Dwyer. &lt;a href=&quot;https://dl.acm.org/doi/full/10.1145/3729354&quot;&gt;Doc2OracLL: Investigating the Impact of Documentation on LLM-Based Test Oracle Generation&lt;/a&gt;. &lt;em&gt;Proceedings of the ACM on Software Engineering&lt;/em&gt;, 2(FSE), 2025. &lt;a href=&quot;#cite-2&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-3&quot;&gt;Jeremy Avigad, Kevin Buzzard, Johan Commelin, Rémy Degenne, Kim Morrison, Oliver Nash and Adam Topaz. &lt;a href=&quot;https://xenaproject.wordpress.com/2026/10/16/how-to-formalize-all-of-mathematics/&quot;&gt;How to Formalize All of Mathematics&lt;/a&gt;. &lt;em&gt;Xena Project blog&lt;/em&gt;, October 2026. &lt;a href=&quot;#cite-3&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-4&quot;&gt;Scott Meyers. &lt;a href=&quot;https://martinfowler.com/ieeeSoftware/designGuideline.pdf&quot;&gt;The Most Important Design Guideline?&lt;/a&gt; &lt;em&gt;IEEE Software&lt;/em&gt;, 21(4), 2004. &lt;a href=&quot;#cite-4&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-5&quot;&gt;David R. MacIver. &lt;a href=&quot;https://drmaciver.com/notebook/2024/01/writing-good-programming-abstractions/&quot;&gt;Writing good programming abstractions&lt;/a&gt;. Blog post, January 2024. &lt;a href=&quot;#cite-5&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
  &lt;li id=&quot;ref-6&quot;&gt;Martin Fowler. &lt;a href=&quot;https://martinfowler.com/bliki/DomainDrivenDesign.html&quot;&gt;Domain Driven Design&lt;/a&gt;. &lt;em&gt;martinfowler.com&lt;/em&gt;, April 2020. &lt;a href=&quot;#cite-6&quot; class=&quot;cite-back&quot; title=&quot;Back to text&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I am primarily not thinking about GUIs, although the same thinking can be applied there. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Though a point is made that “All the boilerplate required just to get the software running is all the accidental complexity. I think LLMs are good at reducing accidental complexity.” They give the example of writing some code to connect two systems: “Need a Spring Boot service that talks to Kafka and logs with OpenTelemetry? An LLM can spit out a working template in seconds.” But in this example the accidental complexity is not reduced; the complexity is still there, it was just outsourced. Any deficiencies in the interfaces (I am not claiming there are any in this example; I do not know these systems) still needs to be worked around by the LLM, and then the resulting code is still present and will need reviewing and reusing by others in the future. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Unmesh mentions this too, contrasting pair programming vs. passive PR reviews. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
  </entry>
  
  <entry>
    <title>Generative AI in research software engineering for science</title>
    <link href="https://dorchard.github.io/blog/2026/10/03/generative-ai-research-software-engineering-science/"/>
    <id>https://dorchard.github.io/blog/2026/10/03/generative-ai-research-software-engineering-science/</id>
    <updated>2026-10-03T00:00:00+00:00</updated>
    <category term="science"/>
    <summary>What impact is generative AI having on research software engineering and scientific computing, and how can we identify where the real benefits could lie?</summary>
    <content type="html">&lt;p&gt;I wrote a post for the &lt;a href=&quot;https://iccs.cam.ac.uk/news/generative-ai-research-software-engineering-science&quot;&gt;Institute of Computing for Climate Science blog&lt;/a&gt; about the potential benefits and risks of generative AI in scientific software development, and why validation, verification and a cautious, evidence-based approach matter.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://iccs.cam.ac.uk/news/generative-ai-research-software-engineering-science&quot;&gt;Read the blog post here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>FirstPrelude v0.2.0 for beginner Haskell using GHC</title>
    <link href="https://dorchard.github.io/blog/2026/01/05/firstprelude/"/>
    <id>https://dorchard.github.io/blog/2026/01/05/firstprelude/</id>
    <updated>2026-01-05T00:00:00+00:00</updated>
    <category term="haskell"/>
    <category term="teaching"/>
    <category term="functional-programming"/>
    <summary>A simplified Prelude for teaching functional programming without type classes getting in the way.</summary>
    <content type="html">&lt;p&gt;I have taught functional programming to Computer Science undergraduates for nine years now, and have used Haskell for at least six of those, specifically using the &lt;a href=&quot;https://www.haskell.org/ghc/&quot;&gt;GHC&lt;/a&gt; implementation. One problem I noticed a few years ago is that many simple programming errors made in GHC-Haskell produce type class errors that
are difficult for students to understand. For example, consider the following attempted code:&lt;/p&gt;

&lt;div class=&quot;language-haskell 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;n&quot;&gt;foo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Bool&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;foo&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mod&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When given to GHC, this gives an error like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;• No instance for (Num (Integer -&amp;gt; Integer))
        arising from the literal ‘0’
        (maybe you haven&apos;t applied a function to enough arguments?)
• In the second argument of ‘(==)’, namely ‘0’
    In the expression: mod x == 0
    In an equation for ‘foo’: foo x = mod x == 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Why? The problem is we forgot to provide the second argument to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mod&lt;/code&gt; in the definition of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foo&lt;/code&gt;. But instead of getting a clear error about a missing argument or type mismatch, we get a cryptic message about a missing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Num&lt;/code&gt; instance for a function type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Integer -&amp;gt; Integer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem is not really GHC itself but the use of overloaded numerics in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt; standard library. If instead
we were using an implementation of Standard ML, these kinds of beginner mistakes would instead result in more cleare error messages. This situation in GHC/Haskell is unfortunate as its pedagogically difficult to teach type classes very early in a course, and so beginners are left without as much support until they learn more topics.&lt;/p&gt;

&lt;p&gt;Other difficulties arise from the use of generalisations in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt;, for example the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;length&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;length :: Foldable t =&amp;gt; t a -&amp;gt; Int&lt;/code&gt;. I don’t want to have to explain type classes and the idea of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Foldable&lt;/code&gt; before teaching the basics of lists!&lt;/p&gt;

&lt;p&gt;Thus, a few years ago I devised a replacement for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt; called &lt;a href=&quot;https://github.com/dorchard/FirstPrelude&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FirstPrelude&lt;/code&gt;&lt;/a&gt; that simplifies the standard library to contain no use of type classes, with much more monomorphised functions. Later, the students can be transitioned to traditional &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt; after learning about type classes.&lt;/p&gt;

&lt;p&gt;The setup is simply to include either:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import Prelude()
import FirstPrelude
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

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

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{-# LANGUAGE NoImplicitPrelude #-}
import FirstPrelude
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;at the start of each file. It would be great if there was a mechanism in GHC to simplify this further, perhaps a special flag for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ghci&lt;/code&gt; to signal ‘education mode’ or perhaps even an alias &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ghcie&lt;/code&gt;. (I am reminded a bit of the progressive language levels idea in &lt;a href=&quot;https://planet.racket-lang.org/archives/wrturtle/pyret.plt/2/1/contents/planet-docs/manual/&quot;&gt;Pyret&lt;/a&gt;). I could give students a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cabal&lt;/code&gt; setup which removes the need to include these lines, but I wanted to still keep things lightweight and not require too much ecosystem setup at the beginning of the term.&lt;/p&gt;

&lt;p&gt;At the start of the new teaching term, I have been doing a few updates to the library and have just made a new release: &lt;a href=&quot;https://github.com/dorchard/FirstPrelude&quot;&gt;v0.2.0.0&lt;/a&gt;. This
closes a few holes that were previously open and could still cause confusion. I’ve hidden even more type classes that were still poking through, e.g., in functions like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;head&lt;/code&gt; which has type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;head :: GHC.Stack.Types.HasCallStack =&amp;gt; [a] -&amp;gt; a&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Of course, another solution to this would have been to use &lt;a href=&quot;https://dl.acm.org/doi/10.1145/871895.871902&quot;&gt;Helium&lt;/a&gt;, an implementation of Haskell which does not have type classes. However, I &lt;em&gt;do&lt;/em&gt; want to teach type classes eventually (usually in the middle of the course), just not immediately!&lt;/p&gt;

&lt;p&gt;In the future, it would be interesting to design some kind of user study that logs student errors using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FirstPrelude&lt;/code&gt; and then after-the-fact looks at what they would have been using normal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Prelude&lt;/code&gt; from which we could calculate how many type-class-based errors are avoided by the use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FirstPrelude&lt;/code&gt;. I’m hoping I can design and deploy such a study at some point, but alas no time this year!&lt;/p&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://hackage.haskell.org/package/FirstPrelude-0.2.0.0&quot;&gt;FirstPrelude on Hackage&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/dorchard/FirstPrelude&quot;&gt;FirstPrelude on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Helium4Haskell/helium&quot;&gt;Helium on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  
  <entry>
    <title>Quick on/off toggling of GenAI autocomplete</title>
    <link href="https://dorchard.github.io/blog/2025/11/19/quick-toggling-genai-autocomplete/"/>
    <id>https://dorchard.github.io/blog/2025/11/19/quick-toggling-genai-autocomplete/</id>
    <updated>2025-11-19T00:00:00+00:00</updated>
    <category term="programming"/>
    <category term="productivity"/>
    <summary>A simple keyboard shortcut to quickly toggle GitHub Copilot on and off in VS Code when you want temporary AI assistance.</summary>
    <content type="html">&lt;p&gt;A long-held view amongst programmers is that keeping your hands on the keyboard, using keyboard shortcuts, is much more efficient than
switching to the mouse and back. I certainly find its true for me, so I often seek to codify tasks into keyboard shortcuts.
I’ve used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;emacs&lt;/code&gt; for many years which is great for this as you can programme it in using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;elisp&lt;/code&gt; and build up complex macros. But I find
myself increasingly using &lt;a href=&quot;https://code.visualstudio.com/&quot;&gt;VS Code&lt;/a&gt; for programming these days, and so I’ve gradually migrated parts of my 
workflow.&lt;/p&gt;

&lt;p&gt;With some caution, I find that the latest generative AI coding assistants (via LLMs) can sometimes be useful (a topic for another blog post),
once there is appropriate validation and verification in place. One mode of interaction with such tools is the ‘auto complete’ style. This
can be useful when working in an unfamiliar language or with an unfamiliar library, or when there is a repeated pattern of code or
something trivial you need doing. But it can also quickly become annoying and more of a hindrance
than a help. I realised that I needed an easy way to toggle gen-AI autocomplete on and off rapidly, without having to waste
time clicking through menus.&lt;/p&gt;

&lt;p&gt;Here’s how I do it in VS Code in case it’s useful for others:&lt;/p&gt;

&lt;h2 id=&quot;adding-the-keyboard-shortcut&quot;&gt;Adding the Keyboard Shortcut&lt;/h2&gt;

&lt;p&gt;Open your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keybindings.json&lt;/code&gt; file in VS Code (you can access it via &lt;strong&gt;Code → Settings → Keyboard Shortcuts&lt;/strong&gt;, then click the “Open Keyboard Shortcuts (JSON)” icon in the top right, or opening up the command palette and typing ‘keyboard’ should reduce the options to show you “Open Keyboard Shortcuts (JSON)”).&lt;/p&gt;

&lt;p&gt;This file contains a list of keybinding records in JSON format, e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[{...}, {...}]&lt;/code&gt;. Add the following entry anywhere inside the list:&lt;/p&gt;

&lt;div class=&quot;language-json 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;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;shift+cmd+;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;github.copilot.completions.toggle&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’ve chosen the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Shift+Cmd+;&lt;/code&gt; combination because it’s easy to reach for me (and easy to remember) and doesn’t overlap with anything else I need. 
I use a couple of Apple Macs hence the use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cmd&lt;/code&gt;, but that could easily be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl&lt;/code&gt; for a non-Mac keyboard; you can of course choose any other combination that suits you better.&lt;/p&gt;

&lt;p&gt;So your file should look something like:&lt;/p&gt;

&lt;div class=&quot;language-json 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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;shift+cmd+;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;github.copilot.completions.toggle&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;your&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;keybindings&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this it is easy to toggle the auto complete on to get some help (hopefully just writing some code I was going to write anyway!)
and then I can easily toggle it off when things get annoying (often!), or I really need or want to figure
it out myself. I have it off a lot of the time, but it’s useful to be able to flick it on, and then back off again, occasionally.
Of course, if you are in another editor, there will be another editor-specific way of doing this, but I’d definitely recommend having
a keyboard shortcut like this if this is a feature you use often.&lt;/p&gt;

&lt;p&gt;Hopefully this helps someone! I’m always recommending to students to get proficient with keyboard shortcuts and customising their workflow to be as efficient as possible, to enable focussed work rather than losing time to navigating a UI and context-switch overhead.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Migrating blog</title>
    <link href="https://dorchard.github.io/blog/2025/10/23/welcome/"/>
    <id>https://dorchard.github.io/blog/2025/10/23/welcome/</id>
    <updated>2025-10-23T00:00:00+00:00</updated>
    <category term="general"/>
    <category term="announcement"/>
    <summary>This is the first post on my new blog, and an attempt to migrate over my old posts from WordPress</summary>
    <content type="html">&lt;p&gt;Blogging… who has time for it? Well, I probably almost don’t, but at the same time I often feel myself
itching to post a few things, e.g., ideas, announcements, little tidbits. And my old blog is a bit old
and crusty, hosted over at Wordpress, which is acting as a barrier to me just getting new, short posts out.
So I’m trying to setup a new system via the Jekyll static HTML setup I have here. Let’s see how it goes.&lt;/p&gt;

&lt;p&gt;I think I was able to import all my old Wordpress based posts at least, apart from the comments.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>New group member: Chinmayi Baramashetru</title>
    <link href="https://dorchard.github.io/blog/2025/03/10/new-group-member/"/>
    <id>https://dorchard.github.io/blog/2025/03/10/new-group-member/</id>
    <updated>2025-03-10T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>We are excited to have Chinmayi Baramashetru(https://chinmayiprabhu.com/) joining the group at Kent as a postdoctoral research associate to work on targetting programming language theory techniques to climate modelling problems. Chinmayi...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;We are excited to have &lt;a href=&quot;https://chinmayiprabhu.com/&quot;&gt;Chinmayi Baramashetru&lt;/a&gt; joining the group at Kent as a postdoctoral research associate 
to work on targetting programming language theory techniques to climate modelling problems. Chinmayi has a background
in formal methods and verification, having recently finished her doctoral studies at the Department of Informatics, University of Oslo, Norway.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Artifact Evaluation at Climate Informatics 2024</title>
    <link href="https://dorchard.github.io/blog/2025/01/02/ci2024-ae/"/>
    <id>https://dorchard.github.io/blog/2025/01/02/ci2024-ae/</id>
    <updated>2025-01-02T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>I am cross-posting a blog post that I wrote on the ICCS blog(https://iccs.cam.ac.uk/news/artifact-evaluation-years-climate-informatics-2024) about the Artifcat Evaluation process we put in place at Climate Informatics 2024 this year.</summary>
    <content type="html">&lt;p&gt;I am cross-posting a blog post that &lt;a href=&quot;https://iccs.cam.ac.uk/news/artifact-evaluation-years-climate-informatics-2024&quot;&gt;I wrote on the ICCS blog&lt;/a&gt; about the Artifact Evaluation process we put in place at Climate Informatics 2024 this year.&lt;/p&gt;

&lt;quote&gt;
  In 2024, the Climate Informatics conference embarked, for the first time, on adding an Artifact Evaluation (AE) process following the standard peer review process. This provided an opportunity to embed the values of reproducibility into the publication process in a lightweight opt-in fashion, thus encouraging authors to make software available and the results of the paper reproducible.  The submitted artifacts were evaluated by a team of reviewers who provided feedback to the authors to help develop their artifacts towards a higher standard of computational reproducibility.

This blog post reports on the background motivation for this endeavour and some details of the process this year.
&lt;/quote&gt;

&lt;p&gt;The full blog post can be &lt;a href=&quot;https://iccs.cam.ac.uk/news/artifact-evaluation-years-climate-informatics-2024&quot;&gt;found here, on the ICCS blog&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>An autumn of my talks on programming languages and software engineering for climate modelling</title>
    <link href="https://dorchard.github.io/blog/2024/11/11/talks/"/>
    <id>https://dorchard.github.io/blog/2024/11/11/talks/</id>
    <updated>2024-11-11T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>It has been an autumn (and November) where I (Dominic) have given quite a few talks about my work in this area.</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;It has been an autumn (and November) where I (Dominic) have given quite a few talks about my work in this area.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;In September, “&lt;a href=&quot;https://drive.google.com/file/d/1D5yguvyIL_ZERBzEioW92OXKdttFuyWA/view?usp=sharing&quot;&gt;&lt;strong&gt;From C to Comonads to Climate - A Functional Programmer’s Journey in Array Programming&lt;/strong&gt;&lt;/a&gt;”  as the keynote at the &lt;a href=&quot;https://icfp24.sigplan.org/home/fproper-2024&quot;&gt;1st ACM SIGPLAN Workshop on Functional Programming for Productivity and Performance (FProPer’24)&lt;/a&gt;, co-located with ICFP 2024 in Milan, Italy.&lt;/li&gt;
  &lt;li&gt;In November, “&lt;a href=&quot;https://drive.google.com/file/d/12CRPiaChoKZ6sfPZoYGvlYnlyQB06P1g/view&quot;&gt;&lt;strong&gt;Computing for Climate Science and Programming for the Planet&lt;/strong&gt;&lt;/a&gt;” at the departmental seminar of the Department of Computer Science and Technology at Cambridge, where I spend half my time, and in short form at Queens’ college at the Monday night SCR talks.&lt;/li&gt;
  &lt;li&gt;Also in November, “&lt;strong&gt;Writing Computational Models that are FAIR and VRAI&lt;/strong&gt;” (slides on request) at the Centre for Atmospheric Science, Yusuf Hamied Department of Chemistry, University of Cambridge.&lt;/li&gt;
  &lt;li&gt;And again in November (busy month!), “&lt;a href=&quot;https://drive.google.com/file/d/1-HT9nRjlaU-Y6Kgj_sGteZ3-DCn6tprj/view?usp=sharing&quot;&gt;&lt;strong&gt;Taming the Black Box - Effectively Leveraging ML Sub-Models (some thoughts and case studies)&lt;/strong&gt;&lt;/a&gt;” at the Cambridge Centre for Climate Science (CCfCS) Winter Symposium 2024, University of Cambridge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the content of these talks is currently in draft stages of a paper I hope to submit in the early new year.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Summer School 2024 training: Typing for Python, Abstract mathematics for Climate Modelling, and some Julia</title>
    <link href="https://dorchard.github.io/blog/2024/09/10/training/"/>
    <id>https://dorchard.github.io/blog/2024/09/10/training/</id>
    <updated>2024-09-10T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>July brought with it the third annual ICCS summer school on software engineering and programming for climate modelling. The full programme of talks is now on YouTube(https://iccs.cam.ac.uk/events/institute-computing-climate-science-annual-summer-school-2024) including my talks/training...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;July brought with it the third annual ICCS summer school on software engineering and programming for climate modelling. The &lt;a href=&quot;https://iccs.cam.ac.uk/events/institute-computing-climate-science-annual-summer-school-2024&quot;&gt;full programme of talks is now on YouTube&lt;/a&gt; including my talks/training on:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=8EiFw47blZs&amp;amp;list=PL3PByZO-B6dM4pw2AwLepEBsfDrly9L0w&amp;amp;index=11&quot;&gt;Typing Python with mypy&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Typing Python with mypy&lt;/strong&gt;
Many compiled languages include a ‘type checker’ as part of their compilation process which applies automated checks to source code to rule out potential runtime errors due to mismatches in the format of data (‘type errors’). The Python language does not include such a check: its types are ‘dynamic’, with type errors occurring only if encountered at runtime. Python however supports type annotations (since Python 3.0) which allows a programmer to insert optional type information into code which external tools can then use to type check a program. This session will teach how to use Python types alongside the mypy tool for ruling out program bugs and better documenting source code. We will also talk about some fundamental concepts in typing and program verification.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=6JRfIOMwEWI&amp;amp;list=PL3PByZO-B6dM4pw2AwLepEBsfDrly9L0w&amp;amp;index=15&quot;&gt;What can abstract mathematics tell us about programming climate models&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What can abstract mathematics tell us about programming climate models?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Category theory is a subfield of mathematics that seeks to expose common underlying structure in other areas of mathematics. It has since also became a foundational technique for understanding logic and programming, with its use both in semantics of formal languages and as a tool for structuring programs. Many concepts in computer programming can be explained from a category theoretic perspective, yielding new insights about how to reason about programs and generalise their definitions. In this session, I will give an overview of a few key ideas that have applications to numerical programming tasks familiar in earth systems modelling. This will provide some fresh perspectives about how to structure and reason about programs both for correctness and efficiency.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;And a contributed a bit to a training/tutorial session on &lt;a href=&quot;https://www.youtube.com/watch?v=IL672h9pTxk&amp;amp;list=PL3PByZO-B6dM4pw2AwLepEBsfDrly9L0w&amp;amp;index=17&quot;&gt;Introduction to Computational Science in Julia &lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I was particularly happy to deliver the second talk here which was a lot of fun, using ideas from category theory to think about how we specify the behaviour of key patterns in numerical modelling and also uses the ideas to motivate optimisations. This was all done in Python, including generating tests from categorical laws. The &lt;a href=&quot;https://github.com/Cambridge-ICCS/training-cats-for-programming&quot;&gt;material is online&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Hiring: 33-month postdoc position opportunity on Programming Languages and Systems for Climate Science</title>
    <link href="https://dorchard.github.io/blog/2024/07/10/hiring/"/>
    <id>https://dorchard.github.io/blog/2024/07/10/hiring/</id>
    <updated>2024-07-10T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>I&apos;m hiring a postdoc to work with me at the University of Kent on programming languages, tools, and systems for climate science in partnership with the Institute of Computing For...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I’m hiring a postdoc to work with me at the University of Kent on programming languages, tools, and systems for 
climate science in partnership with the &lt;a href=&quot;https://iccs.cam.ac.uk/&quot;&gt;Institute of Computing For Climate Science&lt;/a&gt; at Cambrige.&lt;/p&gt;

&lt;p&gt;Details can be found &lt;a href=&quot;https://jobs.kent.ac.uk/Vacancy.aspx?ref=CEMS-264-24&quot;&gt;here&lt;/a&gt;. &lt;strong&gt;Closing date 9th September 2024&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s a video about the position and potential ideas that a succesful candidate could explore:&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/dJ6I2NO_VeU?si=PjaO5mubHgAZIIam&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Potential topics include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Static analysis tooling for numerical models&lt;/li&gt;
  &lt;li&gt;Verification of critical libraries used by scientists&lt;/li&gt;
  &lt;li&gt;Novel language ideas for future computational models&lt;/li&gt;
  &lt;li&gt;Extending existing languages with novel features to support science&lt;/li&gt;
  &lt;li&gt;Developing new tools to support climate scientists&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other ideas possible that I’d love to hear. I’m looking for someone who is excited about applying PL ideas into the climate modelling domain. There will be a chance to work alongside scientists to try out ideas ‘in the field’ through my network.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Dominic co-chairs the 1st ACM Workshop on Programming for the Planet in London</title>
    <link href="https://dorchard.github.io/blog/2024/01/22/propl/"/>
    <id>https://dorchard.github.io/blog/2024/01/22/propl/</id>
    <updated>2024-01-22T00:00:00+00:00</updated>
    <category term="science"/>
    <category term="plas4sci"/>
    <summary>The 1st ACM Workshop on Programming for the Planet(https://popl24.sigplan.org/home/propl-2024) brought together researchers from computer science to discuss how to close the gap between state-of-the-art programming methods being developed in academia...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;The &lt;a href=&quot;https://popl24.sigplan.org/home/propl-2024&quot;&gt;1st ACM Workshop on Programming for the Planet&lt;/a&gt; brought together researchers from computer science to discuss how to close the gap between state-of-the-art programming methods being developed in academia and the use of programming in climate analysis, modelling, forecasting, policy, and diplomacy.&lt;/p&gt;

&lt;p&gt;The event was co-located with the &lt;a href=&quot;https://popl24.sigplan.org/&quot;&gt;51st ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2024)&lt;/a&gt; which gave an excellent opportunity for this community to consider how its research could be targetted and leveraged to address the multiple overlapping planetary crises facing us. The workshop had two keynotes: from &lt;a href=&quot;https://www.cfse.cam.ac.uk/directory/drew_purves&quot;&gt;Drew Purves&lt;/a&gt; of Google DeepMind on ‘&lt;em&gt;Setting the stage for AI biodiversity&lt;/em&gt;’ and &lt;a href=&quot;https://www.lisarennels.com/&quot;&gt;Lisa Rennels&lt;/a&gt; of UC Berkley on ‘&lt;em&gt;Building Open Source Software for Climate Change Research - Lessons Learned from Mimi.jl&lt;/em&gt;’. The contributed talks were grouped into four tracks on ‘Modelling and analysis’, ‘Energy and efficiency’, ‘Software engineering and ecosystems’ and ‘Policy and decision making’. This demonstrated the many angles from which programming languages research could help address our current planetary challenges. &lt;a href=&quot;https://popl24.sigplan.org/home/propl-2024#event-overview&quot;&gt;&lt;strong&gt;See the list of talks here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The event highlighted many exciting works already coming from the Programming Language community but also many opportunities for further cross-disciplinary work. Two discussion session highlighted the need for thinking more broadly and stepping outside the core discipline to look for opportunities where expertise could be applied or where general assistance was given. Co-organisers &lt;a href=&quot;https://dorchard.github.io/&quot;&gt;Dr Dominic Orchard&lt;/a&gt; and &lt;a href=&quot;https://anil.recoil.org/&quot;&gt;Prof Anil Madhavapeddy&lt;/a&gt; are now working to synthesise lessons and a way forward for the community to have transformative change in this area.&lt;/p&gt;

&lt;p&gt;Dominic noted that “&lt;em&gt;it was particularly exciting to see how engaged the students and early-career scientists were with the issues, and the energy and enthusiasm for leveraging their skills to address the significant challenges facing humanity&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://plas4sci.github.io//assets/images/propl1.jpg&quot; style=&quot;max-width:500px;width:25vw;margin:10px;&quot; /&gt;
&lt;img src=&quot;https://plas4sci.github.io//assets/images/propl2.png&quot; style=&quot;max-width:500px;width:25vw;margin:10px;&quot; /&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Training at AIMS Kigali and attending WCRP OSC 2023</title>
    <link href="https://dorchard.github.io/blog/2023/10/29/kigali/"/>
    <id>https://dorchard.github.io/blog/2023/10/29/kigali/</id>
    <updated>2023-10-29T00:00:00+00:00</updated>
    <category term="misc"/>
    <category term="plas4sci"/>
    <summary>Dominic attended the World Climate Research Programme - Open Science Conference 2023(https://wcrp-osc2023.org/) in Kigali, Rwanda in October 2023.</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Dominic attended the &lt;a href=&quot;https://wcrp-osc2023.org/&quot;&gt;World Climate Research Programme - Open Science Conference 2023&lt;/a&gt; in Kigali, Rwanda in October 2023.&lt;/p&gt;

&lt;p&gt;Alongside this, he helped deliver a one-day training workshop at the African Institute for Mathematics on software engineering good practice and programming in the context of climate science. Particularly, Dominic gave a session on using &lt;a href=&quot;https://drive.google.com/file/d/1tuXnrbbND_cHmE5xpgIJ6u--CUaCiX2J/view&quot;&gt;Using types to rule out bugs - Python vs Fortran perspective&lt;/a&gt;, giving an overview of concepts in verification and correctness, and giving practical examples of how to leverage type systems for correctness.&lt;/p&gt;

&lt;p&gt;At the conference, Dominic gave a talk on &lt;a href=&quot;https://drive.google.com/file/d/1ahKWPL3g9lRk4eh8wXzbi0_0DXKpPt9G/view?usp=sharing&quot;&gt;Research Software Engineering for the New Generation of Climate Models&lt;/a&gt; giving an overview of the work of the Institute of Computing for Climate Science and a spotlight on some of
the interesting challenges going forwards.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://iccs.cam.ac.uk/news/iccs-provides-essential-training-software-engineering-ahead-open-science-conference-rwanda&quot;&gt;Read more on the ICCS blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;Photo from AIMS&quot; src=&quot;https://dorchard.github.io/images/kigali/photo1.jpg&quot; style=&quot;width:50%;margin: 0 auto;margin-bottom:10px;&quot; /&gt;&lt;br /&gt;
&lt;img alt=&quot;Photo from AIMS&quot; src=&quot;https://dorchard.github.io/images/kigali/photo2.jpg&quot; style=&quot;width:50%;margin: 0 auto;margin-bottom:10px;&quot; /&gt;&lt;br /&gt;
&lt;img alt=&quot;Photo from AIMS&quot; src=&quot;https://dorchard.github.io/images/kigali/photo3.jpg&quot; style=&quot;width:50%;margin: 0 auto;margin-bottom:10px;&quot; /&gt;&lt;br /&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Presentations at EGU23</title>
    <link href="https://dorchard.github.io/blog/2023/05/04/egu/"/>
    <id>https://dorchard.github.io/blog/2023/05/04/egu/</id>
    <updated>2023-05-04T00:00:00+00:00</updated>
    <category term="misc"/>
    <category term="plas4sci"/>
    <summary>Dominic attended the European Geosciences Union, EGU23(https://egu23.eu/) in Vienna, which provided a great opportunity to catch-up with many of our scientific collaborators, especially in the DataWave(https://datawaveproject.github.io/) and SASIP(https://sasip-climate.github.io/) teams. There...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Dominic attended the &lt;a href=&quot;https://egu23.eu/&quot;&gt;European Geosciences Union, EGU23&lt;/a&gt; in Vienna, which provided a great
opportunity to catch-up with many of our scientific collaborators, especially in the &lt;a href=&quot;https://datawaveproject.github.io/&quot;&gt;DataWave&lt;/a&gt;
and &lt;a href=&quot;https://sasip-climate.github.io/&quot;&gt;SASIP&lt;/a&gt; teams. There were a number of presentations of our work during the week:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://crd.lbl.gov/divisions/scidata/uds/staff/gilberto-pastorello/&quot;&gt;Gilberto Pastorello&lt;/a&gt; from the Lawrence Berkeley
National Laboratory presented our collaboration on the &lt;a href=&quot;https://github.com/fluxnet/ONEFlux&quot;&gt;ONEFlux&lt;/a&gt; data processing
tool for land-atmopshere cabord flux, with a poster presentation (&lt;a href=&quot;https://meetingorganizer.copernicus.org/EGU23/EGU23-11187.html?pdf&quot;&gt;corresponding abstract&lt;/a&gt;).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;At the DataWave side meeting, Jack Atkinson from &lt;a href=&quot;https://cambridge-iccs.github.io/&quot;&gt;ICCS&lt;/a&gt; presented &lt;a href=&quot;https://cambridge-iccs.github.io/climate-informatics-2023/assets/pdfs/Reducing_the_overhead_of_coupled_ML_models.pdf&quot;&gt;our work&lt;/a&gt;
on improving interoperation between Fortran and pythonic machine learning libaries, applied to the Gravity Wave Drag parameterizations in atmospheric models.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;At the DataWave side meeting, I presented a short talk about &lt;a href=&quot;https://dorchard.github.io/slides/egu-datawave-camfort.pdf&quot;&gt;Analysis and lightweight verification of Fortran code&lt;/a&gt; using
the CamFort tool and demonstrated some of its lightweight static analysis tooling by running it live on the MiMA moist atmospheric
model.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  
  <entry>
    <title>Presentation and extended abstract at Climate Informatics 2023</title>
    <link href="https://dorchard.github.io/blog/2023/04/21/ci2023/"/>
    <id>https://dorchard.github.io/blog/2023/04/21/ci2023/</id>
    <updated>2023-04-21T00:00:00+00:00</updated>
    <category term="misc"/>
    <category term="plas4sci"/>
    <summary>Dominic was local organizer for the Climate Informatics 2023(https://cambridge-iccs.github.io/climate-informatics-2023/) conference in Cambridge, 19-21st April, where Simon Clifford presented our work in progress on improving interoperation between Fortran and pythonic machine...</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This post is cross-posted from the &lt;a href=&quot;https://plas4sci.github.io/&quot;&gt;Programming Languages and Systems for Science&lt;/a&gt; blog.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Dominic was local organizer for the &lt;a href=&quot;https://cambridge-iccs.github.io/climate-informatics-2023/&quot;&gt;Climate Informatics 2023&lt;/a&gt; conference
in Cambridge, 19-21st April, where Simon Clifford presented our work in progress on
&lt;a href=&quot;https://cambridge-iccs.github.io/climate-informatics-2023/assets/pdfs/Reducing_the_overhead_of_coupled_ML_models.pdf&quot;&gt;improving interoperation between Fortran and pythonic machine learning libaries&lt;/a&gt;
applied to the Gravity Wave Drag parameterizations in atmospheric models.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/FuFdrrLWcAYCCZa?format=jpg&amp;amp;name=4096x4096&quot; alt=&quot;Dominic talking&quot; style=&quot;max-width:900px;width:50vw;&quot; /&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>A short exploration of GHC&apos;s instance resolution hiding mistakes from the type checker.</title>
    <link href="https://dorchard.github.io/blog/2020/06/03/a-short-exploration-of-ghcs-instance-resolution-hiding-mistakes-from-the-type-checker/"/>
    <id>https://dorchard.github.io/blog/2020/06/03/a-short-exploration-of-ghcs-instance-resolution-hiding-mistakes-from-the-type-checker/</id>
    <updated>2020-06-03T00:00:00+00:00</updated>
    <category term="haskell"/>
    <summary>I was recently working on some Haskell code (for research, with Jack Hughes) and happened to be using a monoid (via the Monoid type class) and I was rushing. I accidentally wrote x `mempty` y instead of x `mappend` y. The code with mempty type checked and compiled, but I...</summary>
    <content type="html">&lt;p&gt;I was recently working on some Haskell code (for research, with &lt;a href=&quot;https://twitter.com/jackolhughes&quot;&gt;Jack Hughes&lt;/a&gt;) and happened to be using a monoid (via the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid&lt;/code&gt; type class) and I was rushing. I accidentally wrote &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x &lt;/code&gt;mempty&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; y&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x &lt;/code&gt;mappend&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; y&lt;/code&gt;. The code with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; type checked and compiled, but I quickly noticed some tests giving unexpected results. After a pause, I checked the recent diff and noticed this mistake, but I had to think for a moment about why this mistake was not leading to a type error. I thought this was an interesting little example of how type class instance resolution can sometimes trip you up in Haskell, and how to uncover what is going on. This also points to a need for GHC to explain its instance resolution, something others have thought about; I will briefly mention some links at the end.&lt;/p&gt;

&lt;h2 id=&quot;the-nub-of-the-problem&quot;&gt;The nub of the problem&lt;/h2&gt;

&lt;p&gt;In isolation, my mistake was essentially this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;whoops :: Monoid d =&amp;gt; d -&amp;gt; d -&amp;gt; d
whoops x y = mempty x y  -- Bug here. Should be &quot;mappend x y&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, given two parameters of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; for which there is a monoid structure on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt;, we use both parameters as arguments to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt;. Recall the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid&lt;/code&gt; type class is essentially:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;class Monoid d where
  mempty :: d
  mappend :: d -&amp;gt; d -&amp;gt; d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(note that ​​&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid&lt;/code&gt; also has a derived operation &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mconcat&lt;/code&gt; and is now decomposed into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Semigroup&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid&lt;/code&gt; but I elide that detail here, see &lt;a href=&quot;https://hackage.haskell.org/package/base-4.14.0.0/docs/Prelude.html#t:Monoid&quot;&gt;https://hackage.haskell.org/package/base-4.14.0.0/docs/Prelude.html#t:Monoid&lt;/a&gt;). We might naively think that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whoops&lt;/code&gt; would therefore not type check since we do not know that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; is a function type. However, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whoops&lt;/code&gt; &lt;strong&gt;is&lt;/strong&gt; well-typed and evaluating &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whoops [1,2,3] [4,5,6]&lt;/code&gt; returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[]&lt;/code&gt;. If the code had been as I intended, (using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mappend&lt;/code&gt; here instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt;) then we would expect &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[1,2,3,4,5,6]&lt;/code&gt; according to the usual monoid on lists. The reason this is not a type error is because of GHC’s instance resolution and the following provided instance of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;instance Monoid b =&amp;gt; Monoid (a -&amp;gt; b) where
  mempty = \_ -&amp;gt; mempty
  mappend f g = \x -&amp;gt; f x `mappend` g x
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That is, functions are monoids if their domain is a monoid with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; as the constant function returning the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; element of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mappend&lt;/code&gt; as the pointwise lifting of a monoid to a function space. In this case, we can dig into what is happening by compiling1 with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ddump-ds-preopt&lt;/code&gt; and looking at GHC’s desugared output before optimisation, where all the type class instances have been resolved. I’ve cleaned up the output a little (mostly renaming):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;whoops :: forall d. Monoid d =&amp;gt; d -&amp;gt; d -&amp;gt; d
whoops = \ (@ d) ($dMonoid :: Monoid d) -&amp;gt;
  let
    $dMonoid_f :: Monoid (d -&amp;gt; d)
    $dMonoid_f = GHC.Base.$fMonoid-&amp;gt; @ d @ d $dMonoid }

    $dMonoid_ff :: Monoid (d -&amp;gt; d -&amp;gt; d)
    $dMonoid_ff = GHC.Base.$fMonoid-&amp;gt; @ (d -&amp;gt; d) @ d $dMonoid_f }
  in
    \ (x :: d) (y :: d) -&amp;gt; mempty @ (d -&amp;gt; d -&amp;gt; d) $dMonoid_ff x y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The second line shows &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whoops&lt;/code&gt; has a type parameter (written &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@ d&lt;/code&gt;) and the incoming dictionary &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$dMonoid&lt;/code&gt; representing the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid d&lt;/code&gt; type class instance (type classes are implemented as data types called dictionaries, and I use the names &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$dMonoidX&lt;/code&gt; for these here). Via the explicit type application (of the form &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@ t&lt;/code&gt; for a type term &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt;) we can see in the last line that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; is being resolved at the type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d -&amp;gt; d -&amp;gt; d&lt;/code&gt; with the monoid instance &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid (d -&amp;gt; d -&amp;gt; d)&lt;/code&gt; given here by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$dMonoid_ff&lt;/code&gt; construction just above. This is in turn derived from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid (d -&amp;gt; d)&lt;/code&gt; given by the dictionary construction &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$dMonoid_f&lt;/code&gt; just above that. Thus we have gone twice through the lifting of a monoid to a function space, and so our use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; here is:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mempty @ (d -&amp;gt; d -&amp;gt; d) $dMonoid_ff = \_ -&amp;gt; (\_ -&amp;gt; mempty @ $dMonoid)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

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

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mempty @ (d -&amp;gt; d -&amp;gt; d) $dMonoid_ff x y = mempty @ d $dMonoid
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s why the program type checks and we see the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mempty&lt;/code&gt; element of the original intended monoid on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; when applying &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whoops&lt;/code&gt; to some arguments and evaluating.&lt;/p&gt;

&lt;h2 id=&quot;epilogue&quot;&gt;Epilogue&lt;/h2&gt;

&lt;p&gt;I luckily spotted my mistake quite quickly, but this kind of bug can be a confounding experience for beginners. There has been some discussion about extending GHCi with a feature allowing users to ask GHC to explain its instance resolution. Michael Sloan has a nice &lt;a href=&quot;https://mgsloan.com/posts/inspecting-haskell-instance-resolution/&quot;&gt;write up discussing the idea&lt;/a&gt; and there is a &lt;a href=&quot;https://gitlab.haskell.org/ghc/ghc/issues/15613&quot;&gt;GHC ticket proposing&lt;/a&gt; by &lt;a href=&quot;https://gitlab.haskell.org/Icelandjack&quot;&gt;Icelandjack&lt;/a&gt; something similar which seems like it would work well in this context where you want to ask what the instance resolution was for a particular expression. There are many much more confusing situations possible that get hidden by the implicit nature of instance resolution, so I think this would be a very useful feature, for beginner and expert Haskell programmers alike. And it certainly would have explained this particular error quickly to me without me having to scribble on paper and then check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ddump-ds-preopt&lt;/code&gt; to confirm my suspicion. &lt;strong&gt;Additional&lt;/strong&gt; : I should also point out that this kind of situation could be avoided if there were ways to scope, import, and even name type class instances. The monoid instance &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monoid b =&amp;gt; Monoid (a -&amp;gt; b)&lt;/code&gt; is very useful, but having it in scope &lt;em&gt;by default&lt;/em&gt; as part of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;base&lt;/code&gt; was really the main issue here.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;1 To compile, put this in a file with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; stub, e.g.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;main :: IO ()
main = return ()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
  </entry>
  
  <entry>
    <title>Considering the order of results when computing Cartesian product [short]</title>
    <link href="https://dorchard.github.io/blog/2019/08/02/considering-the-order-of-results-when-computing-cartesian-product-short/"/>
    <id>https://dorchard.github.io/blog/2019/08/02/considering-the-order-of-results-when-computing-cartesian-product-short/</id>
    <updated>2019-08-02T00:00:00+00:00</updated>
    <category term="haskell"/>
    <category term="maths"/>
    <summary>Sometimes in programming you need to do a pairwise comparison of some elements coming from two collections, for example, checking possible collisions between particles (which may be embedded inside a quadtree representation for efficiency). A handy operation is then the Cartesian product of the two sets of elements, to get...</summary>
    <content type="html">&lt;p&gt;Sometimes in programming you need to do a pairwise comparison of some elements coming from two collections, for example, checking possible collisions between particles (which may be embedded inside a &lt;a href=&quot;https://en.wikipedia.org/wiki/Quadtree&quot;&gt;quadtree&lt;/a&gt; representation for efficiency). A handy operation is then the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cartesian_product&quot;&gt;Cartesian product&lt;/a&gt; of the two sets of elements, to get the set of all pairs, which can then be traversed. Whenever I need a Cartesian product of two lists in Haskell, I whip out the &lt;a href=&quot;https://en.wikibooks.org/wiki/Haskell/Understanding_monads/List&quot;&gt;list monad&lt;/a&gt; to generate the Cartesian product:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cartesianProduct :: [a] -&amp;gt; [b] -&amp;gt; [(a, b)]
cartesianProduct as bs = as &amp;gt;&amp;gt;= (\a -&amp;gt; bs &amp;gt;&amp;gt;= (\b -&amp;gt; [(a, b)]))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Thus for every element &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;as&lt;/code&gt; we get every element &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bs&lt;/code&gt; and form the singleton list of the pair &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(a, b)&lt;/code&gt;, all of which get concatenated to produce the result. For example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;*Main&amp;gt; cartesianProduct [1..4] [1..4]
[(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3),(4,4)]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This traverses the Cartesian space in row order. That is, if we imagine the square grid of possibilities here (where the element at the ith row and jth column corresponds to element &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(i, j)&lt;/code&gt;), then &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cartesianProduct&lt;/code&gt; generates the pairs in the following order: &lt;img src=&quot;https://dorchard.wordpress.com/wp-content/uploads/2019/08/cp-roworder.png&quot; alt=&quot;cp-rowOrder&quot; /&gt; In mathematics, the Cartesian product is defined on sets, so the order of these pairs is irrelevant. Indeed, if we want to examine all pairs, then it may not matter in what order. However, if we learn something as we look at the pairs (i.e., accumulating some state), then the order can be important. In some recent research, I was building an automated algebra tool to find axioms for some algebraic structure, based on an interpretation. This involved generating all pairs of syntax trees &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&apos;&lt;/code&gt; of terms over the algebraic structure, up to a particular depth, and evaluating whether &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t = t&apos;&lt;/code&gt;. I also had some automated proof search machinery to make sure that this equality wasn’t already derivable from the previously generated axioms. I could have done this derivability check as a filtering afterwards, but I was exploring a very large space, and did not expect to even be able to generate all the possibilities. I just wanted to let the thing run for a few hours and see how far it got. Therefore, I needed Cartesian product to get all pairs, but the order in which I generated the pairs became important for the effectiveness of my approach. The above ordering (&lt;a href=&quot;https://en.wikipedia.org/wiki/Row-_and_column-major_order&quot;&gt;row major order&lt;/a&gt;) was not so useful as I was unlikely to find interesting axioms quickly by traversing the span of a (very long) row; I needed to unpack the space in a more balanced way. My first attempt at a more balanced Cartesian product was the following:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cartesianProductBalanced :: [a] -&amp;gt; [b] -&amp;gt; ([(a, b)])
cartesianProductBalanced as bs =
     concatMap (zip as) (tails bs)
  ++ concatMap (flip zip bs) (tail (tails as))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tails&lt;/code&gt; gives the list of successively applying &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tail&lt;/code&gt;, e.g., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tails [1..4]&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[[1,2,3,4],[2,3,4],[3,4],[4],[]]&lt;/code&gt; This definition for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cartesianProductBalanced&lt;/code&gt; essentially traverses the diagonal of the space and then the &lt;a href=&quot;https://en.wikipedia.org/wiki/Triangular_matrix&quot;&gt;lower triangle &lt;/a&gt;of the matrix, progressing away from the diagonal to the bottom-left, then traversing the upper triangle of the matrix (the last line of code), progressing away from the diagonal to the top-right corner. The ordering for a 4x4 space is then:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;*Main&amp;gt; cartesianProductBalanced [1..4] [1..4]
[(1,1),(2,2),(3,3),(4,4),(1,2),(2,3),(3,4),(1,3),(2,4),(1,4),(2,1),(3,2),(4,3),(3,1),(4,2),(4,1)]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dorchard.wordpress.com/wp-content/uploads/2019/08/cp-low-then-upper.png&quot; alt=&quot;cp-low-then-upper&quot; /&gt; This was more balanced, giving me a better view of the space, but does not scale well: traversing the elements of this Cartesian product linearly means first traversing all the way down the diagonal, which could be very long! So, we’ve ended up with a similar problem to the row-major traversal. Instead, I finally settled on a “tiling” Cartesian product:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cartesianProductTiling :: [a] -&amp;gt; [b] -&amp;gt; [(a, b)]
cartesianProductTiling [] _ = []
cartesianProductTiling _ [] = []
cartesianProductTiling [a] [b] = [(a, b)]
cartesianProductTiling as bs =
       cartesianProductTiling as1 bs1
    ++ cartesianProductTiling as2 bs1
    ++ cartesianProductTiling as1 bs2
    ++ cartesianProductTiling as2 bs2
  where
    (as1, as2) = splitAt ((length as) `div` 2) as
    (bs1, bs2) = splitAt ((length bs) `div` 2) bs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This splits the space into four quadrants and recursively applies itself to the upper-left, then lower-left, then upper-right, then lower-right, e.g.,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;*Main&amp;gt; cartesianProductTiling [1..4] [1..4]
[(1,1),(2,1),(1,2),(2,2),(3,1),(4,1),(3,2),(4,2),(1,3),(2,3),(1,4),(2,4),(3,3),(4,3),(3,4),(4,4)]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dorchard.wordpress.com/wp-content/uploads/2019/08/cp-tiling-1.png&quot; alt=&quot;cp-tiling&quot; /&gt; Thus, we explore the upper-left portion first, without having to traverse down a full row, column, or diagonal. This turned out to be much better for my purposes of searching the space of possible axioms for an algebraic structure. Note that this visits the elements in &lt;a href=&quot;https://en.wikipedia.org/wiki/Z-order_curve&quot;&gt;Z-order&lt;/a&gt; (also known as the Lebesgue space-filling curve) [Actually, it is a reflected Z-order curve, but that doesn’t matter here]. The only downside to this tiling approach is that it does not work for infinite spaces (as it calculates the length of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;as&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bs&lt;/code&gt;), so we cannot exploit Haskell’s laziness here to help us in the infinite case. I’ll leave it as an exercise for the reader to define a tiling version that works for infinite lists. Of course, there are many other possibilities depending on your application domain!&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Later edit: In the case of the example I mentioned, I actually do not need the full Cartesian product since the order of pairs was not relevant to me (equality is symmetric) and neither do I need the pairs of identical elements (equality is reflexive). So for my program, computing just the lower triangle of Cartesian product square is much more efficient, i.e,:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cartesianProductLowerTriangle :: [a] -&amp;gt; [b] -&amp;gt; [(a, b)]
cartesianProductLowerTriangle as bs = concatMap (zip as) (tail (tails bs))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, this does not have the nice property of tiling product where we visit the elements in a more balanced fashion. I’ll leave that one for another day (I got what I needed from my program in the end anyway).&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>At the end of 2018</title>
    <link href="https://dorchard.github.io/blog/2018/12/31/at-the-end-of-2018/"/>
    <id>https://dorchard.github.io/blog/2018/12/31/at-the-end-of-2018/</id>
    <updated>2018-12-31T00:00:00+00:00</updated>
    <category term="advice"/>
    <category term="general"/>
    <summary>As 2018 draws to a close, I wanted to share a couple of personal thoughts from the year: one related to success/failure and the other on resolutions, which I&apos;ll cover first. Following tradition, I often make several informal New Years&apos; resolutions, usually involving health/fitness goals. My level of success in...</summary>
    <content type="html">&lt;p&gt;As 2018 draws to a close, I wanted to share a couple of personal thoughts from the year: one related to success/failure and the other on resolutions, which I’ll cover first. Following tradition, I often make several informal New Years’ resolutions, usually involving health/fitness goals. My level of success in keeping these resolutions tends to also be traditional: stick with it for 2-3 weeks then forget about it. Last year I realised my problem is that I usually make too many resolutions, and I make resolutions that are not realistic given all my other constraints. Therefore, at the start of 2018, I made just &lt;strong&gt;one&lt;/strong&gt; resolution: &lt;em&gt;keep a daily record of my activities&lt;/em&gt;. The format I chose for this daily record was a Google Drive spreadsheet (for easy multi-device access), with columns for various things I want to be aware of and try to improve in some way: bed time, wake time, diet related items such as fruit and vegetable intake, alcohol, time spent reading (for work), exercise, quiet time in the mornings, and so on. I’m proud to say that I kept my resolution every single day. The time commitment was low (1-2 minutes before bed), and it quickly had a positive impact on the goals of previous years. My spreadsheet included fixed rows providing the mean so far for most columns. This was a useful guide throughout the year. I had some vague goals and the data allowed me to perform “course corrections” as the year progressed. Towards the end of the year, it got harder to affect the means, but this almost became a challenge: e.g., “can I shave just 2 minutes off my average bed time before the end of the year?”. A quick bit of programming provided me with some further data analysis tools for some interesting insight into daily/weekly patterns throughout the year: for some reason I went to bed latest on Wednesdays on average (probably cramming lecture prep)! My resolution for 2019 is to continue, but now I have some more clear goals in mind. I also have a new set of columns. Some information wasn’t that useful, and there are other things I want to improve that are easily measured and tracked. These items can now be easily integrated into the whole process. Recently, I also realised that I could include a quick micro-journal (a couple of summary sentences about the day), which I would like to continue in 2019. As someone who has struggled to keep up daily routines and disciplines, I have found this all immensely helpful. I did not see an improvement in every column, but it did improve some markedly. I’d recommend this technique highly to anyone. Lastly, a thought on failure. As the year draws to its end, I’ve been thinking about my successes and failures in 2018. It’s always easy to focus on the failures, especially in academia where there are often many. This year has certainly had many difficulties and disappointments, along with some successes. The thing that is so pernicious about failure is that it is hungry and it will devour as much as you let it devour. Instead, we have to try to integrate the failure into our selves positively, in a way that strengthens, in a way that teaches and informs. Otherwise, we will just let failure swallow up the rest of our success, energy, drive, creativity, joy, and everything else. So at the end of the year, I’m trying to dwell less on the existence of the failures, but more on what they’ve taught me for the future and what might emerge out of the ashes. That’s the only way forward, otherwise failure wins and eats everything else up. So, happy new year! See many of you in 2019. I hope you have a great start to the year. I’m looking forward to travelling to Lisbon shortly for POPL 2019 where I will be giving a &lt;a href=&quot;https://blog.metatheorem.org/2018/11/08/POPL-Tutorial.html&quot;&gt;tutorial&lt;/a&gt; on &lt;a href=&quot;https://granule-project.github.io/&quot;&gt;the Granule project&lt;/a&gt; joint with &lt;a href=&quot;http://metatheorem.org/&quot;&gt;Harley Eades&lt;/a&gt; and my student &lt;a href=&quot;https://github.com/buggymcbugfix&quot;&gt;Vilem Liepelt.&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Exam advice</title>
    <link href="https://dorchard.github.io/blog/2018/04/04/exam-advice/"/>
    <id>https://dorchard.github.io/blog/2018/04/04/exam-advice/</id>
    <updated>2018-04-04T00:00:00+00:00</updated>
    <category term="advice"/>
    <summary>Part of my job is to give advice to my undergraduate students about exam technique and preparing for exams. I was always quite nervous about exams &apos;back in the day&apos;, and I put a lot of effort into revising and planning. In retrospect, I think I enjoyed these times: I...</summary>
    <content type="html">&lt;p&gt;Part of my job is to give advice to my undergraduate students about exam technique and preparing for exams. I was always quite nervous about exams “back in the day”, and I put a lot of effort into revising and planning. In retrospect, I think I enjoyed these times: I have many happy memories of long days and evenings studying with my friends (whose presence and encouragement made it a lot more palatable). This year, I decided to serialise my advice and put it online in case it can be of any help or inspiration to others either taking exams, or giving exam advice. I’m sure I can think of more advice, so I made it a GitHub “gist” so I can revise it whenever more advice pops into my head. https://gist.github.com/dorchard/f7b9b95fe93c118fd1880197bcdfe196&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Scrap Your Reprinter</title>
    <link href="https://dorchard.github.io/blog/2017/09/20/scrap-your-reprinter/"/>
    <id>https://dorchard.github.io/blog/2017/09/20/scrap-your-reprinter/</id>
    <updated>2017-09-20T00:00:00+00:00</updated>
    <category term="paper"/>
    <category term="programming languages"/>
    <summary>Back in 2013, Andrew Rice and I were doing some initial groundwork on how to build tools to help scientists write better code (e.g., with the help of refactoring tools and verification tools). We talked to a lot of scientists who wrote Fortran almost exclusively, so we started creating infrastructure...</summary>
    <content type="html">&lt;p&gt;Back in 2013, &lt;a href=&quot;http://www.cl.cam.ac.uk/~acr31/&quot;&gt;Andrew Rice&lt;/a&gt; and I were doing some initial groundwork on how to build tools to help scientists write better code (e.g., with the help of refactoring tools and verification tools). We talked to a lot of scientists who wrote Fortran almost exclusively, so we started creating infrastructure for building tools to work on Fortran. This was the kernel of the &lt;a href=&quot;http://camfort.github.io&quot;&gt;CamFort&lt;/a&gt; project for which we got an EPSRC grant in 2015 (which is ongoing). The CamFort tool now has a couple of fairly well developed specification/verification features, and a few refactoring features. Early on, I started building everything in Haskell using the brilliant &lt;a href=&quot;http://hackage.haskell.org/package/uniplate&quot;&gt;uniplate&lt;/a&gt; library, based on the Scrap Your Boilerplate [1] work. This helped us to get the tool off the ground quickly by utilising the power of datatype generic programming. Fairly quickly we hit upon an interesting problem with building refactoring tools: how do you output source code for a refactored AST whilst preserving all the original comments and white space? It is not enough just to pretty print the AST, unless your AST contains &lt;strong&gt;all&lt;/strong&gt; the comments and layout information. Building a parser to capture all this information is extremely hard, and we use a parser generator which limits flexibility (but is really useful for a large grammar). Another approach is to output patch/edit information for the original source code, calculated from the AST. In the end, I came up with a datatype generic algorithm which I call the &lt;em&gt;reprinter.&lt;/em&gt; The reprinter takes the original source code and an updated AST (which contains location information) and maps them into a new piece of source code. Here is an illustration which I’ll briefly explain: &lt;img src=&quot;https://dorchard.wordpress.com/wp-content/uploads/2017/09/reprinter.png&quot; alt=&quot;reprinter&quot; /&gt; Some source text (arithmetic code in prefix notation here) is parsed into an AST. The AST contains the “spans” of each syntactic fragment: the start position and end position in the original source code (for simplicity in this illustration, just the column number is represented). Some transformation/refactoring is applied next. In this case, the transformation rewrites redundant additions of 0, which happens in the node coming from source locations 10 to 16. The refactored node is marked in red. The reprinting then runs, stitching together the original source code with the updated source tree. A pretty printer is used to generate code for any new nodes, but all the original source text for the other nodes is preserved. The cool thing about this algorithm is that it is datatype generic: it works for any datatype, with some modest side conditions about storing source spans. The implementation uses the Scrap Your Zipper [2] library to do a context-dependent generic traversal of a datatype. In essence, the algorithm is similar to what one might do if you were to spit out edit information from an AST, then apply this to a piece of source text. But, the algorithm does this generically, and in a single simultaneous pass of the AST and the input source text. I’ve always thought it was a cute and useful algorithm, which combined some cool techniques from functional programming. As with all the “Scrap Your X” libraries it saves huge amounts of time and messing around, especially when your AST representation keeps changing (which it did/does for us). The algorithm is really useful anywhere you need to update human-written source code in a layout-preserving way; for example, IDEs and refactoring tools but also in interactive theorem provers and program synthesis tools, where you need to synthesise source text into some existing human-written code. This is one of the ways it is used in CamFort, where specifications are synthesised from code analysis data and then inserted as comments into user code. This summer, I was fortunate enough to have the resources to hire several interns. One of the interns, &lt;a href=&quot;https://github.com/harry-clarke&quot;&gt;Harry Clarke&lt;/a&gt;, (amongst other things) worked with me to tidy up the code for the reprinter, add some better interfaces, make it usable &lt;a href=&quot;http://hackage.haskell.org/package/reprinter&quot;&gt;as a library for others&lt;/a&gt;, and write it all up. He presented the work at &lt;a href=&quot;http://iflconference.org/cfp.html&quot;&gt;IFL 2017&lt;/a&gt; and &lt;a href=&quot;https://www.cs.kent.ac.uk/people/staff/dao7/publ/reprinter2017.pdf&quot;&gt;the pre-proceedings version of the paper is available&lt;/a&gt;. We are working on a post-proceedings version for December, so any comments gratefully appreciated.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;[1] Lämmel, Ralf, and Simon Peyton Jones. Scrap your boilerplate: a practical design pattern for generic programming. Vol. 38. No. 3. ACM, 2003. [2] Adams, Michael D. “Scrap your zippers: a generic zipper for heterogeneous types.”  &lt;em&gt;Proceedings of the 6th ACM SIGPLAN workshop on Generic programming&lt;/em&gt;. ACM, 2010.&lt;/p&gt;
</content>
  </entry>
  
</feed>
