- October 21st, 2016:
You have l1 :: [(v, [(k, x)])]
You need the transformation l2 :: [(k, [(v, x)])]
Redistribute v and k in one line
Props for elegance - Francisco T @aiceou redist xs = fromListWith (++) $ concat $ (map f xs) where f (a,ys) = map (\(x,y) -> (x,[(a,y)])) ys ... but k has to be 'Ord'