renderIssues repo issues =
    header <> foldr renderIssue "\n" issues' <> footer
    where
        issues' = V.concat $ issues ^.. traverse . key "items" . _Array

        renderIssue :: Value -> Builder -> Builder
        renderIssue  i = mappend (renderIssue' i)
        renderIssue' i =
            F.build "#{}: [{}] {}\n"
                ( F.Shown . fromMaybe ((-1) :: Int) $ i ^? key "number" . _Integral
                , state $ i ^? key "state" . _String
                , fromMaybe "<Untitled>" $ i ^? key "title" . _String
                )

        state :: Maybe T.Text -> Builder
        state (Just "open")   = " "
        state (Just "closed") = "*"
        state Nothing         = "?"

        header = "## Issues\n\n"
        footer = F.build "{} issues.\n\n" . F.Only $ V.length issues'
renderIssues repo issues =
    header <> foldr renderIssue "\n" issues' <> footer
    where
        issues' = V.concat $ issues ^.. traverse . key "items" . _Array

        renderIssue :: Value -> Builder -> Builder
        renderIssue  i = mappend (renderIssue' i)
        renderIssue' i =
            F.build "#{}: [{}] {}\n"
                ( F.Shown . fromMaybe ((-1) :: Int) $ i ^? key "number" . _Integral
                , state $ i ^? key "state" . _String
                , fromMaybe "<Untitled>" $ i ^? key "title" . _String
                )

        state :: Maybe T.Text -> Builder
        state (Just "open")   = " "
        state (Just "closed") = "*"
        state Nothing         = "?"

        header = "## Issues\n\n"
        footer = F.build "{} issues.\n\n" . F.Only $ V.length issues'
renderIssues repo issues =
    header <> foldr renderIssue "\n" issues' <> footer
    where
        issues' = V.concat $ issues ^.. traverse . key "items" . _Array

        renderIssue :: Value -> Builder -> Builder
        renderIssue  i = mappend (renderIssue' i)
        renderIssue' i =
            F.build "#{}: [{}] {}\n"
                ( F.Shown . fromMaybe ((-1) :: Int) $ i ^? key "number" . _Integral
                , state $ i ^? key "state" . _String
                , fromMaybe "<Untitled>" $ i ^? key "title" . _String
                )

        state :: Maybe T.Text -> Builder
        state (Just "open")   = " "
        state (Just "closed") = "*"
        state Nothing         = "?"

        header = "## Issues\n\n"
        footer = F.build "{} issues.\n\n" . F.Only $ V.length issues'