Blog

Unifying Structured Recursion Schemes

by Nicolas Wu

Posted on 20 March 2014

Tags: Haskell


Last year at ICFP 2013 I presented Unifying Structured Recursion Schemes, which was joint work with Ralf Hinze and Jeremy Gibbons. A few people asked me if I would be able to make the presentation available online, so here it is on youtube: The talk dances over a lot of the interesting details, so I hope that if you’re interested, you’ll read the paper. You can download a copy here. Here’s the abstract: Folds over inductive datatypes are well understood and widely used. In their plain form, they are quite restricted; but many disparate generalisations have been proposed that enjoy ...

Read More

The Conditional Choice Operator

by Nicolas Wu

Posted on 1 August 2011

Tags: Haskell


A recent reddit post asking for a library of conditional one-liners and combinators reminded me of one of my favourite operators: the conditional choice. Most programmers are used to the so-called McCarthy conditional: if p then x else y An alternative way of viewing this is as a ternary operator: x <| p |> y This operator is known as the conditional choice, but I’m told that it was introduced by Tony Hoare, so maybe naming it the Hoare conditional would make more sense (it makes an appearance in Hoare’s work on Communicating Sequential Processes ...

Read More

Do The Hokey Cokey

by Nicolas Wu

Posted on 18 April 2011

Tags: Category Theory


A recent blog post by Jeremy Gibbons, Morality and Temptation, left the exercise of finding two definitions of the arrow with the signature μFνF, and showing that they are equivalent. This post shows my solution to this problem, and while I’m here, I too have a confession to make: when dealing with the ins and outs of initial algebras and final coalgebras I sometimes get the Hokey Cokey playing in my mind. For those of you who don’t know this children’s song, it goes something like this: You put your left foot in,
Your left foot ...

Read More

Injective Representables

by Nicolas Wu

Posted on 7 April 2011

Tags: Category Theory


In this article I’ll show how the injective and surjective properties of a function have a nice relationship with the injectivity of the corresponding representable functors, and how the right cancellative definition of surjection can be derived from the standard one. This is a fairly trivial discussion about a simple observation, so don’t expect anything spectacular. The definition of injectivity is usually given in the following terms, where a function is injective when it is left cancellative: h is injective iff f, gh.f = h.gf = g Surjectivity can be described in ...

Read More

Rho-llercoaster Rides

by Nicolas Wu

Posted on 16 January 2011

Tags: Haskell


Last week I attended the London Haskell Hoodlums meetup, where we worked on solving one of the Google Code Jam problems. If you’re relatively new to Haskell, I can definitely recommend these kinds of meetings: they’re a great way of learning how to tackle problems in a functional style. This post is about the solution I came up with on the journey home, and uses an unusual characterisation of an unfold. The problem is to calculate how much money a roller coaster ride makes in a day, where each time a person completes a ride £1 is made. People queue ...

Read More