Idioms

Conor McBride, Nottingham University

In a tale from the implementation of Epigram, I shall tell of an abstraction which made itself too useful to ignore. Idioms are a class of functor equipped with a 'return' and an 'application'. In Haskell,

class Idiom i where
ii :: x -> i x
(<%>) :: i (s -> t) -> i s -> i t

Idioms provide a notion of effectful computation which is more limited than the monadic notion, but by the same token, more readily available. Every monad induces an idiom but, without a 'bind', idioms do not necessarily allow values from one computation to determine the effects in another. This extra rigidity makes idioms closed under composition without further ado. Many type constructors admit the 'threading' of idiomatic computations in a standard way, leading to a small collection of powerful programming combinators with a diverse array of uses which I shall illustrate by a variety of examples.