My favourite view patterns and some proofs in Idris.
You can also do this in your favourite dependently typed PL (well, maybe not).
Inspired by Conor McBride and James McKinna's classic.
You can also see Philip Wadler's awesome paper for some background on this.
"views let you view your data in funny new ways." — Conor McBride