The changes … shined a national spotlight

In particular, the usage of “shined” over “shone” seemed very unnatural to me. As a result of doing a little research on this, both words have now completely lost any meaning. I hope that someone reads this blog post so it was all worth it.

My first stop was the entry on Wiktionary, which lists both “shined” and “shone” as equally acceptable simple past or participle forms. I didn’t think that this was quite right, so I continued my digging. A search for “shined or shone” revealed the usual mass of grammar blogs. The top result was Grammarist, which has a very short entry saying that historically, “shone” was for something emitting light, and “shined” was for polishing something, although in modern usage this is less strictly adhered to. Most other results had a similar, although not quite the same, transitive vs intransitive distinction. One even mentioned a mnemonic “rhyme”: “shone stands alone”.

I put “rhyme” in scare quotes there because in my (British English RP) accent it doesn’t rhyme at all: “shone” as in “gone” and “alone” as in “moan”. This reinforces my initial intuition that there is some British vs American difference here. Inspired by my favourite blog about such differences, Separated by a Common Language, whose post on this I only thought to search for after doing all this other research myself, I looked up the two words in a corpus:

And there we have it: “shone” is proportionally much more common in British (and Commonwealth) English than it is in American. Now you should go read that SbaCL post because it’s written by someone who actually studies this stuff for a living.

]]>I’ve never been a prolific blogger or writer of anything much in particular. At school, essay subjects were my least favourite, and after my English GCSE, the most words I put together in one go were in my UCAS personal statement. Over my undergraduate degree I ended up writing more, as higher level maths leads to more involved proofs needing more explanation, but it’s a very different style to general prose.

On the other hand, from a young age I was a prolific reader. I think I mostly inherited this from my mother, but it became an important part of my personality growing up. I wasn’t fussy: novels, short stories, popular science books, random magazines lying around the house. My reading habit has waxed and waned over the years, but I was always aware of the existence of people who put words together for a living.

Now I’m a PhD student, and for the first time I have to write journal papers and eventually (though a lot sooner than I like to think about) a full thesis. The most consistent piece of writing advice I’ve seen is simply to write as much as possible and not care that the first x thousand words will suck. So one reason is definitely to get to the the point of being able to explain complex topics clearly and engagingly, at least to expert audiences.

With that said, merely practising the art of writing isn’t the only motivating factor. I haven’t come up with a title or tagline for this website mostly to leave myself the freedom to write what I, and hopefully others, find interesting. Granted, so far that’s been weird parts of category theory and overcoming very specific technical issues in little-used software, but I have some thoughts about the broader world of modern society and technology that I want to get to very soon. In fact, this post is at least the start of unravelling all those issues.

Another aspect is to rubber-duck my life in some sense. It’s a common experience to start asking some question (technical or otherwise) and realise that the act of structuring it into words makes the solution clearer, and I hope to be able to apply this to real-life situations I find myself in, ideally where I can come up with some novel or useful observation. I don’t have anything particular in mind in this genre yet, but it’s something that I want to leave myself open to.

And finally, I may eventually have some political or philosophical opinions I want to clarify and share. This builds on my previous point, as the aim is to not only rubber-duck myself into some sort of coherent thinking, but also force myself to do the research. I’m a big believer in intellectual humility, and there’s a lot that I freely admit I don’t know enough about to have even a private opinion of.

So this post will stand, at least for now, as my justification for this exercise in putting words on the internet. As always, if you have any comments, feedback or anything else to say to me, I’d welcome it via email, Twitter, carrier pigeon or any other means of contact you have.

]]>`.html`

suffixes everywhere (inspired by/ripped off from Rohan Jain) initially didn’t quite work right with it, so I’ll document how I fixed this below.
In the original method, clean URLs are implemented in two parts: first `cleanRoute`

routes `foo.md`

to `foo/index.html`

, and then `cleanIndexUrls`

rewrites internal links to remove all the `index.html`

suffixes; see the post for more details. Up to now, this worked well enough, but when the feeds are generated, `index.html`

is left in the links, and on closer inspection, it’s missing the point somehow. Hakyll URLs are generated via the `url`

field attached to `defaultContext`

, which eventually comes from the following:

```
urlField :: String -> Context a
urlField key = field key $
fmap (maybe empty toUrl) . getRoute . itemIdentifier
```

So we can see that it all comes down to the `Route`

of the item. In the case of `cleanRoute`

, this is going to include the `index.html`

. Rather than including this in the URLs and then stripping them out later with `cleanIndexUrls`

, it seems much cleaner to redefine the `url`

field in the context to something more canonically correct. Thus:

```
cleanUrlField :: String -> Context a
cleanUrlField key = field key $
fmap (maybe empty (cleanIndex . toUrl)) .
getRoute .
itemIdentifier
myContext :: Context String
myContext =
cleanUrlField "url" <>
defaultContext
```

With this change, we don’t need to run `cleanIndexUrls`

any more, and the feed generator code picks up the correct URL to place in the Atom and RSS feeds. You can see the full `site.hs`

file with these changes here.

A monad (on some category \( \mathcal{C} \) ), historically also known as a triple, consists of three pieces of data:

- a functor \( T : \mathcal{C} \rightarrow \mathcal{C} \);
- a natural transformation \( \eta = \eta^T : 1 \rightarrow T \) called the
*unit*; and - a natural transformation \( \mu = \mu^T: TT \rightarrow T \) called
*multiplication*

such that \( \mu \circ T\mu = \mu \circ \mu T \) (associativity) and \( \mu \circ T \eta = \mu \circ \eta T = 1 \) (unit law), famously summarised as “a monad is a monoid in the category of endofunctors”^{1}. Given a monad \( T \), we may form its *Kleisli category* \( \mathbf{Kl}(T) \), which has the same objects as the underlying category and where an arrow \( X \nrightarrow Y \) is a \( \mathcal{C} \)-arrow \( X \rightarrow TY \). I’ll use this different notation for Kleisli arrows because it’s important to keep straight the distinction between them and arrows in the underlying category. The identities are given by the unit maps \( \eta_X \) and composition of \(f: X \nrightarrow Y\) and \(g: Y \nrightarrow Z\) uses the multiplication:

\[ X \xrightarrow{f} TY \xrightarrow{Tg} TTZ \xrightarrow{\mu_Z} TZ \]

This construction is well-known from its use in functional programming to model effects.

Distributive laws come up a lot in the world of string diagrams and SMTs, where we use them to combine two theories together subject to some laws governing their interaction. The most familiar example of a distributive law is multiplication over addition: \[ a(b + c) = ab + ac \] Beck (p95) extended the notion to monads, defining a law distributing a monad \(S\) over a monad \(T\) to be a natural transformation \(\lambda: ST \rightarrow TS\) satisfying certain coherence laws. In the paper, he in fact gives a way to recover the multiplication/addition law back from this construction, which is pretty cool.

The main theorem related to distributive laws of monads is the equivalence of

- a distributive law of \(S\) over \(T\);
- a coherent multiplication on \(TS\);
- a lifting of \(T\) to the category of \(S\)-algebras (which I haven’t introduced, since it isn’t really relevant to this post); and
- a lifting of \(S\) to the Kleisli category of \(T\).

Now, this certainly is true, but this is where the hole appears. Beck’s original paper omits this last condition (perhaps because Kleisli categories weren’t widespread back then?). On the other hand, Cheng implicitly assumes the result for Kleisli categories. I have a feeling that it possibly follows out of the treatment of adjoint functors in Section 3 in the Beck paper, but I can’t quite get my head around it, and in any case I needed to write the construction down from first principles for my application.

To warm up, let’s look at the most well-known use for a distributive law \(\lambda : ST \to TS\): giving the composite functor \(TS\) a monad structure. Simply composing the units \(\eta^T \circ \eta^S \) gives a natural transformation which will be the unit of the composite monad, but the bit which actually requires a distributive law is defining a multiplication \(\mu^{TS} : TSTS \rightarrow TS \). It’s one of those times when there’s essentially only one thing you can write down, and that is exactly what you need:

\[ TSTS \xrightarrow{T \lambda S} TTSS \xrightarrow{\mu^T \mu^S} TS \]

and all the relevant coherence conditions match up to satisfy the monad laws.

For the Kleisli category, we need to define a monad \(\tilde{S}\) on \(\mathbf{Kl}(T)\). Even just to define the functor part we already need the distributive law: the objects are the same, but for a map \(f: X \nrightarrow Y\), we need to define

\[ \tilde{S}f: SX \rightarrow TSY = SX \xrightarrow{Sf} STY \xrightarrow{\lambda_Y} TSY \]

So handwaving over the proofs that this is a proper functor, we now just need a unit and multiplication. The unit is again just a composite of the constituent units: \[ \eta_X: X \nrightarrow \tilde{S}X = X \xrightarrow{\eta^S_X} SX \xrightarrow{\eta^T_{SX}} TSX \] and the multiplication is a little more fiddly, but still straightforward: \[ \mu_X: \tilde{S}\tilde{S}X \nrightarrow \tilde{S}X = SSX \xrightarrow{\mu^S_X} SX \xrightarrow{S\eta^T_X} STX \xrightarrow{\lambda_X} TSX \] And, again glossing over all the annoying coherence proofs, we’re done!

There are quite a few pieces I’ve left out of all of this, notably going back the other way, from a lifting of \(S\) to \(\mathbf{Kl}(T)\) to a distributive law \(ST \rightarrow TS\), and most of the verifications that all these things satisfy the laws they are supposed to, but this is mostly what I wanted to figure out. Hopefully it’s useful to someone other than me. Any mistakes or comments, send me an email or tweet and I’d be happy to discuss.

Still to be done are re-implementing some sort of mobile/responsive design, adding a more formal CV, generating an RSS feed, and perhaps even a publication list. There are also no doubt plenty of places that could use a little prettification; I make no claims to being talented at web design.

]]>