Skip to content

Instantly share code, notes, and snippets.

@paulcc
paulcc / group_on-full-example.hs
Created September 5, 2012 17:37
Example to accompany my types in haskell article
-- compiles with ghc(i) 7.4.1
import Data.Map (Map, empty, insertWith, toList)
import Data.List(groupBy, group, sortBy, sort)
{- To recap from the main article, we want to define "group_on" via "groupBy", so that its
type is something like (b -> b -> Bool) -> (a -> b) -> [a] -> [(b, [a])]
The method here is to work with a concrete example and gradually massage it
into the form we want - using the REPL