Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. data Grade = F | D | C | B | A deriving (Eq,Ord,Enum,Show,Read)
  2. data Degree = HS | BA | MS | PhD deriving (Eq,Ord,Enum,Show,Read)
  3.  
  4. data Candidate = Candidate
  5. { candidateId :: Int
  6. , codeReview :: Grade
  7. , cultureFit :: Grade
  8. , education :: Degree
  9. } deriving (Show)
  10.  
  11. viable :: Candidate -> Bool
  12. viable candidate = all (== True) tests
  13. where passedCoding = (codeReview candidate) >= B
  14. passedCultureFit = (cultureFit candidate) > C
  15. educationMin = (education candidate) >= MS
  16. tests = [passedCoding,passedCultureFit,educationMin]
  17.  
  18. candidate1 :: Candidate
  19. candidate1 = Candidate
  20. { candidateId = 1
  21. , codeReview = A
  22. , cultureFit = A
  23. , education = BA
  24. }
  25. candidate2 :: Candidate
  26. candidate2 = Candidate
  27. { candidateId = 2
  28. , codeReview = C
  29. , cultureFit = A
  30. , education = PhD
  31. }
  32. candidate3 :: Candidate
  33. candidate3 = Candidate
  34. { candidateId = 3
  35. , codeReview = A
  36. , cultureFit = B
  37. , education = MS
  38. }
  39.  
  40. candidates :: [Candidate]
  41. candidates = [ candidate1
  42. , candidate2
  43. , candidate3
  44. ]
  45.  
  46. assessCandidateList :: [Candidate] -> [String]
  47. assessCandidateList candidates = do
  48. candidate <- candidates
  49. let passed = viable candidate
  50. let statement = if passed then "passed" else "failed"
  51. return statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement