forked from haskell-github/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowUser.hs
More file actions
52 lines (45 loc) · 1.88 KB
/
ShowUser.hs
File metadata and controls
52 lines (45 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module ShowUser where
import qualified Github.Users as Github
import Data.Maybe (fromMaybe)
main = do
possibleUser <- Github.userInfoFor "mike-burns"
putStrLn $ either (("Error: "++) . show) formatUser possibleUser
formatUser user@(Github.DetailedOrganization {}) =
"Organization: " ++ (formatName userName login) ++ "\t" ++
(fromMaybe "" company) ++ "\t" ++
(fromMaybe "" location) ++ "\n" ++
(fromMaybe "" blog) ++ "\t" ++ "\n" ++
htmlUrl ++ "\t" ++ (formatDate createdAt) ++ "\n\n" ++
(fromMaybe "" bio)
where
userName = Github.detailedOwnerName user
login = Github.detailedOwnerLogin user
company = Github.detailedOwnerCompany user
location = Github.detailedOwnerLocation user
blog = Github.detailedOwnerBlog user
htmlUrl = Github.detailedOwnerHtmlUrl user
createdAt = Github.detailedOwnerCreatedAt user
bio = Github.detailedOwnerBio user
formatUser user@(Github.DetailedUser {}) =
(formatName userName login) ++ "\t" ++ (fromMaybe "" company) ++ "\t" ++
(fromMaybe "" location) ++ "\n" ++
(fromMaybe "" blog) ++ "\t" ++ "<" ++ email ++ ">" ++ "\n" ++
htmlUrl ++ "\t" ++ (formatDate createdAt) ++ "\n" ++
"hireable: " ++ (formatHireable isHireable) ++ "\n\n" ++
(fromMaybe "" bio)
where
userName = Github.detailedOwnerName user
login = Github.detailedOwnerLogin user
company = Github.detailedOwnerCompany user
location = Github.detailedOwnerLocation user
blog = Github.detailedOwnerBlog user
email = Github.detailedOwnerEmail user
htmlUrl = Github.detailedOwnerHtmlUrl user
createdAt = Github.detailedOwnerCreatedAt user
isHireable = Github.detailedOwnerHireable user
bio = Github.detailedOwnerBio user
formatName Nothing login = login
formatName (Just name) login = name ++ "(" ++ login ++ ")"
formatHireable True = "yes"
formatHireable False = "no"
formatDate = show . Github.fromGithubDate