2.1. pattern-matchinggood first issue
Repository metrics
- Stars
- (46 stars)
- PR merge metrics
- (PR metrics pending)
Description
During the coding of the Hood-Melville queue, I encountered an error message when I had put in a pattern matching an exact value of one of the parameters. Simplifying the issue:
- For this interpreter gives error:
data NoneNegativeInt = NNInt of Int
let subOne value =
match value with
| NNInt 0 => NNInt 0
| NNInt n => NNInt (n-1)
end
- For this interpreter doesn't give error:
data NoneNegativeInt = Zero | NNInt of Int
let subOne value =
match value with
| Zero => Zero
| NNInt n => if n == 1 then Zero else NNInt (n - 1)
end
I think it would be great to be able to write matches like in the first point.