mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
refactor: use function for overflow Tag in std.rs
This commit is contained in:
parent
cfbc4d1c54
commit
d3d3497b46
1 changed files with 9 additions and 7 deletions
|
@ -75,17 +75,19 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
),
|
||||
);
|
||||
|
||||
// addChecked : Num a, Num a -> Result (Num a) [ Overflow ]*
|
||||
let overflow = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("Overflow".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
fn overflow() -> SolvedType {
|
||||
SolvedType::TagUnion(
|
||||
vec![(TagName::Global("Overflow".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
)
|
||||
}
|
||||
|
||||
// addChecked : Num a, Num a -> Result (Num a) [ Overflow ]*
|
||||
add_type(
|
||||
Symbol::NUM_ADD_CHECKED,
|
||||
top_level_function(
|
||||
vec![num_type(flex(TVAR1)), num_type(flex(TVAR1))],
|
||||
Box::new(result_type(num_type(flex(TVAR1)), overflow.clone())),
|
||||
Box::new(result_type(num_type(flex(TVAR1)), overflow())),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -115,7 +117,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
Symbol::NUM_SUB_CHECKED,
|
||||
top_level_function(
|
||||
vec![num_type(flex(TVAR1)), num_type(flex(TVAR1))],
|
||||
Box::new(result_type(num_type(flex(TVAR1)), overflow)),
|
||||
Box::new(result_type(num_type(flex(TVAR1)), overflow())),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue