Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. type PullRequestState
  2. = Proposed
  3. | Rejected
  4. | Merged
  5.  
  6. branchColor : PullRequestState -> String
  7. branchColor state =
  8. case state of
  9. Proposed ->
  10. "yellow"
  11.  
  12. Rejected ->
  13. "red"
  14.  
  15. Merged ->
  16. "green"
  17. --------------------------------------------------
  18. type Availability
  19. = SoldOut
  20. | InStock Int
  21. | Reordered ( Int, Int )
  22. | Announced String
  23.  
  24.  
  25. displayStatus : Availability -> String
  26. displayStatus availability =
  27. case availability of
  28. SoldOut ->
  29. "Sold out"
  30.  
  31. InStock amount ->
  32. "In stock: " ++ String.fromInt amount ++ " left."
  33.  
  34. Reordered days ->
  35. let
  36. min =
  37. days
  38. |> Tuple.first
  39. |> String.fromInt
  40.  
  41. max =
  42. days
  43. |> Tuple.second
  44. |> String.fromInt
  45. in
  46. "Available again in " ++ min ++ " to " ++ max ++ " days."
  47.  
  48. Announced date ->
  49. "Available on " ++ date ++ "."
  50.  
  51.  
  52. foo =
  53. displayStatus (InStock 42)
  54. -- "In stock: 42 left." : String
  55.  
  56. bar =
  57. displayStatus (Reordered ( 3, 5 ))
  58. -- "Available again in 3 to 5 days." : String
  59.  
  60.  
  61. baz =
  62. displayStatus (Announced "2016-12-24")
  63. -- "Available on 2016-12-24." : String
  64.  
  65.  
  66. availabilities : List Availability
  67. availabilities =
  68. [ SoldOut
  69. , InStock 42
  70. , Reordered ( 3, 5 )
  71. ]
  72.  
  73.  
  74. bob =
  75. List.map displayStatus availabilities
  76. -- ["Sold out","In stock: 42 left.","Available again in 3 to 5 days."] : List Str
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement