Does Elm have anything between an *if-then-else* flow control and* case* ?

My use case is, I need to parse a string in various ways to decide which 
Analysis ADT to assign to the string.

Thus

sconvert : String -> Analysis
sconvert s =
     if s=="all" then AllDays
     else if s=="unplayed" then Unplayed
     else if String.startsWith "onday" s then OnDay (secondBit s)
     else if String.contains "totz:" s then Totz (secondBit s)
     else Unknown


There are about 30 different branches in my app, and it's convenient to 
keep them together.

I can't use a case expression here, so I guess what I'm looking for is 
something like F#'s match expression, where you can add conditions using 
the when modifier. (code written as if the function existed in Elm

fizzBuzz : Int -> String
fizzBuzz x = 
    match x with 
    | i when i % 15 = 0 ->  "fizzbuzz" 
    | i when i % 3 = 0 -> "fizz" 
    | i when i % 5 = 0 ->  "buzz" 
    | i  -> toString(i)

What would be an elegant way to implement the fizzBuzz function in Elm?
      

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to