[#286] Improve `ArithError` to remove impossible representation
Description
Problem: We have
-- | Denotes the error type occured in the arithmetic operation.
data ArithErrorType
= AddOverflow
| MulOverflow
| SubUnderflow
| LslOverflow
| LsrUnderflow
deriving stock (Show, Eq, Ord, Generic)
-- | Represents an arithmetic error of the operation.
data ArithError n m
= MutezArithError ArithErrorType n m
| ShiftArithError ArithErrorType n m
deriving stock (Show, Eq, Ord, Generic)
LslOverflow
and LsrUnderflow
can only happen in ShiftArithError
and
the other three can only be part of MutezArithError
. But it's not
reflected in type.
Solution: Turn ArithErrorType
into two types: ShiftArithErrorType
and MutezArithErrorType
.
Related issue(s)
Resolves #286 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Moremi Vannak