Last active
October 15, 2015 01:24
-
-
Save lotz84/f5e9f4042876559e40d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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