--------------------------------------------------------------------------------
-- Contributors
--------------------------------------------------------------------------------
data Contributor = Contributor
{ contributorName :: Text
, contributorGithub :: Text
, contributorCount :: Int
}
toJSON Contributor{..} =
object [ "name" .= contributorName
, "github" .= contributorGithub
, "count" .= contributorCount
]
parseJSON = withObject "Contributor" $ \v -> Contributor
<$> v .: "name"
<*> v .: "github"
<*> v .: "count"
Contributor _name1 github1 count1 <> Contributor name2 github2 count2
= if github1 == github2
then Contributor name2 github2 (count1 `max` count2)
else error $ printf "Cannot merge unrelated contributors '%s' and '%s'" github1 github2