error-message-catalog icon indicating copy to clipboard operation
error-message-catalog copied to clipboard

Pattern matching on literals only

Open pdavidow opened this issue 8 years ago • 0 comments

string_Random_TreeRandomInsertStyle = "Insert Random L/R"
string_Right_TreeRandomInsertStyle = "Insert Right"
string_Left_TreeRandomInsertStyle = "Insert Left"

treeRandomInsertStyleDecoder : String -> Decoder TreeRandomInsertStyle
treeRandomInsertStyleDecoder value =
    case value of
        string_Random_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Random
        string_Right_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Right
        string_Left_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Left
        _ -> Decode.fail "Invalid TreeRandomInsertStyle

gives

The following pattern is redundant. Remove it.

90|         string_Right_TreeRandomInsertStyle -> Decode.succeed TreeRandomInsertStyle.Right
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any value with this shape will be handled by a previous pattern.

but should rather state that Elm only matches against literals not values

pdavidow avatar Nov 27 '17 00:11 pdavidow