Open avh4 opened 8 years ago
To use the union type I changes the result to have this format and the decoder type instead of Result
:
fromStringSize : String -> Decoder Size
fromStringSize string =
case string of
"SizeLarge" ->
Decode.succeed SizeLarge
"SizeSmall" ->
Decode.succeed SizeSmall
_ ->
Decode.fail ("Not valid pattern for decoder to Size. Pattern: " ++ toString string)
This input
yields
which incorrectly has the type of
fromStringInterestLevel : InterestLevel -> Result String String
. It should befromStringInterestLevel : String -> Result String InterestLevel
.Also, the generated code for
decodeInterestLevel
should bedecodeInterestLevel = Json.Decode.customDecoder Json.Decode.string fromStringInterestLevel