mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +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 ]*
|
fn overflow() -> SolvedType {
|
||||||
let overflow = SolvedType::TagUnion(
|
SolvedType::TagUnion(
|
||||||
vec![(TagName::Global("Overflow".into()), vec![])],
|
vec![(TagName::Global("Overflow".into()), vec![])],
|
||||||
Box::new(SolvedType::Wildcard),
|
Box::new(SolvedType::Wildcard),
|
||||||
);
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// addChecked : Num a, Num a -> Result (Num a) [ Overflow ]*
|
||||||
add_type(
|
add_type(
|
||||||
Symbol::NUM_ADD_CHECKED,
|
Symbol::NUM_ADD_CHECKED,
|
||||||
top_level_function(
|
top_level_function(
|
||||||
vec![num_type(flex(TVAR1)), num_type(flex(TVAR1))],
|
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,
|
Symbol::NUM_SUB_CHECKED,
|
||||||
top_level_function(
|
top_level_function(
|
||||||
vec![num_type(flex(TVAR1)), num_type(flex(TVAR1))],
|
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