Skip to content

Instantly share code, notes, and snippets.

@lotz84
Last active October 15, 2015 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lotz84/f5e9f4042876559e40d2 to your computer and use it in GitHub Desktop.
Save lotz84/f5e9f4042876559e40d2 to your computer and use it in GitHub Desktop.
import Data.List (sortOn)
import Data.Traversable (for)
import Github.Data
import Github.Repos
organizations :: [String]
organizations = [ "aws", "google", "facebook", "Microsoft", "cookpad", "CyberAgent"
, "DeNADev", "pepabo", "gree", "hatena", "kayac", "mixi-inc", "naver"
, "niftycloud", "pixiv", "rakuten-ws", "airbnb", "adobe-webplatform"
--
, "Automattic", "dropbox", "evernote", "Flipboard", "git", "github"
, "GNOME", "heroku", "IBM"
--
, "Instagram", "linkedin", "mixpanel", "movabletype", "OculusVR"
, "paypal", "twitter", "WordPress", "yahoo", "Netflix", "prezi"
--
, "twilio"
]
main = do
repos <- for organizations $ \org -> do
res <- organizationRepos org
case res of
Left e -> print e >> error "An error occurred!"
Right repos -> return (org, filter onlyHaskellRepo repos)
putStrLn . unlines . map makeMarkdown . reverse . sortOn (length . snd) $ repos
onlyHaskellRepo :: Repo -> Bool
onlyHaskellRepo repo = case repoLanguage repo of
Nothing -> False
Just lang -> lang == "Haskell"
makeMarkdown :: (String, [Repo]) -> String
makeMarkdown (org, repos) = init . unlines $ (header : map repo2Md repos)
where
header = "* **" ++ org ++ "**"
repo2Md r = concat
[ " * [" ++ repoName r ++ "](" ++ repoHtmlUrl r ++ ")"
, maybe "" (\d -> if null d then "" else "\n * " ++ d) $ repoDescription r
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment