jonsterling/Vinyl — pull request #16 by nkpart (2013-05-15 04:39:42+00:00)
Title: Folding across a homogenous record

It needs some type annotating to make it all work (on account of the second FoldRec type parameter). But it's pretty cool:

> let rec = fixRecord $ (Field :: "a" ::: Int) =: 5 <+> (Field :: "b" ::: Int) =: 6

> foldRec (liftA2 (+)) (pure 0) rec :: Identity Int
11
> recToList rec :: [Identity Int]
[5,6]

In crafting these examples, I've realised there's probably uses in an API that accounts for the Functor but this works for what I wanted :)