feat: Num.toStr

* add type for Num.toStr
  * create new lowlevel
  * delete types and Symbol for fromInt and fromFloat
  * leave LowLevel::{StrFromFloat,StrFromInt}
  * match on LowLevel::NumToStr and figure out the layout to decide
    which build function to delegate to
This commit is contained in:
rvcas 2021-11-30 14:52:06 -05:00
parent d67cc883ca
commit f995a07029
8 changed files with 65 additions and 75 deletions

View file

@ -385,6 +385,13 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
// maxI128 : I128
add_type!(Symbol::NUM_MAX_I128, i128_type());
// toStr : Num a -> Str
add_top_level_function_type!(
Symbol::NUM_TO_STR,
vec![num_type(flex(TVAR1))],
Box::new(str_type())
);
// Float module
// div : Float a, Float a -> Float a
@ -618,13 +625,6 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(nat_type())
);
// fromInt : Int a -> Str
add_top_level_function_type!(
Symbol::STR_FROM_INT,
vec![int_type(flex(TVAR1))],
Box::new(str_type())
);
// repeat : Str, Nat -> Str
add_top_level_function_type!(
Symbol::STR_REPEAT,
@ -702,13 +702,6 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(list_type(u8_type()))
);
// fromFloat : Float a -> Str
add_top_level_function_type!(
Symbol::STR_FROM_FLOAT,
vec![float_type(flex(TVAR1))],
Box::new(str_type())
);
// List module
// get : List elem, Nat -> Result elem [ OutOfBounds ]*