Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type PullRequestState
- = Proposed
- | Rejected
- | Merged
- branchColor : PullRequestState -> String
- branchColor state =
- case state of
- Proposed ->
- "yellow"
- Rejected ->
- "red"
- Merged ->
- "green"
- --------------------------------------------------
- type Availability
- = SoldOut
- | InStock Int
- | Reordered ( Int, Int )
- | Announced String
- displayStatus : Availability -> String
- displayStatus availability =
- case availability of
- SoldOut ->
- "Sold out"
- InStock amount ->
- "In stock: " ++ String.fromInt amount ++ " left."
- Reordered days ->
- let
- min =
- days
- |> Tuple.first
- |> String.fromInt
- max =
- days
- |> Tuple.second
- |> String.fromInt
- in
- "Available again in " ++ min ++ " to " ++ max ++ " days."
- Announced date ->
- "Available on " ++ date ++ "."
- foo =
- displayStatus (InStock 42)
- -- "In stock: 42 left." : String
- bar =
- displayStatus (Reordered ( 3, 5 ))
- -- "Available again in 3 to 5 days." : String
- baz =
- displayStatus (Announced "2016-12-24")
- -- "Available on 2016-12-24." : String
- availabilities : List Availability
- availabilities =
- [ SoldOut
- , InStock 42
- , Reordered ( 3, 5 )
- ]
- bob =
- List.map displayStatus availabilities
- -- ["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