module Graphics.LambdaCube.Utility where import Data.List groupSetBy f l = foldl' g [] l where g el e = case partition ((f e) . head) el of { ([],el') -> [e]:el' ; ([gl],el') -> (e:gl):el' ; _ -> error "Invalid case!" }