% 2 == 0) return num * 2; else return undefind; } var doubled = evenDouble(10) if(doubled === undefined) { return “odd number”; } return “num: ${num}”; evenDouble num = if num % 2 == 0 then Just num * 2 else Nothing case (evenDouble 10) of Just num -> “num: ” ++ toString num Nothing -> “odd number”
Elm type Key = Up | Down | Left | Right toKeyCode key = case key of UP -> 38 DOWN -> 40 Left -> 37 Right -> 39 case が値を返す パターン漏れはコンパイラが検知、不思議なケー スはカバーする必要がない