fram-lang / fram-lang/dbl

Pattern matching with literals

Open
#137 1 comment 0 reactions 1 assignee Claimed by @lidiapodoluk View on GitHub
2.1. pattern-matching good first issue
Dominant language
OCaml
Stars
45
Forks
28
PR merge metrics
No merged PRs in 30d

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:
1) 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
```
2. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.