diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index defff8359e..59c1dd428b 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1806,7 +1806,8 @@ fn expose_function_to_host_help<'a, 'ctx, 'env>( // STEP 3: build a {} -> u64 function that gives the size of the return type let size_function_type = env.context.i64_type().fn_type(&[], false); - let size_function_name: String = format!("{}_size", roc_function.get_name().to_str().unwrap()); + let size_function_name: String = + format!("roc_{}_size", roc_function.get_name().to_str().unwrap()); let size_function = env.module.add_function( size_function_name.as_str(), @@ -2119,8 +2120,9 @@ pub fn build_closure_caller<'a, 'ctx, 'env>( // STEP 1: build function header + // e.g. `roc__main_1_Fx_caller` let function_name = format!( - "{}_{}_caller", + "roc_{}_{}_caller", def_name, alias_symbol.ident_string(&env.interns) ); @@ -2200,7 +2202,7 @@ pub fn build_closure_caller<'a, 'ctx, 'env>( // STEP 3: build a {} -> u64 function that gives the size of the return type let size_function_type = env.context.i64_type().fn_type(&[], false); let size_function_name: String = format!( - "{}_{}_size", + "roc_{}_{}_size", def_name, alias_symbol.ident_string(&env.interns) ); diff --git a/examples/effect/Main.roc b/examples/effect/Main.roc index c13c2afb63..2e37d4be5b 100644 --- a/examples/effect/Main.roc +++ b/examples/effect/Main.roc @@ -1,31 +1,11 @@ -app "effect-example" provides [ main ] imports [ Effect, RBTree ] - -toAndFro : Int -toAndFro = - empty : RBTree.Dict Int {} - empty = RBTree.empty - - empty - |> (\d -> RBTree.insert 1 {} d) - |> RBTree.toList - |> List.len - - - +app "effect-example" imports [ Effect, RBTree ] provides [ main ] to "./platform" main : Effect.Effect {} as Fx main = - # if RBTree.isEmpty empty then - if toAndFro == 2 then + if RBTree.isEmpty (RBTree.insert 1 2 Empty) then Effect.putLine "Yay" |> Effect.after (\{} -> Effect.getLine) |> Effect.after (\line -> Effect.putLine line) else Effect.putLine "Nay" - -# Effect.always "Write a thing" -# |> Effect.map (\line -> Str.concat line "!") -# |> Effect.after (\line -> Effect.putLine line) -# |> Effect.after (\{} -> Effect.getLine) -# |> Effect.after (\line -> Effect.putLine line) diff --git a/examples/effect/RBTree.roc b/examples/effect/RBTree.roc index 6278d3eafd..1c792e5125 100644 --- a/examples/effect/RBTree.roc +++ b/examples/effect/RBTree.roc @@ -1,4 +1,4 @@ -interface RBTree exposes [ Dict, empty, size, singleton, isEmpty, insert, remove, update, fromList, toList ] imports [] +interface RBTree exposes [ Dict, empty, size, singleton, isEmpty, insert, remove, update, fromList, toList, balance ] imports [] # The color of a node. Leaves are considered Black. NodeColor : [ Red, Black ] diff --git a/examples/effect/platform/src/lib.rs b/examples/effect/platform/src/lib.rs index 1e8554f4c3..ba517b18c8 100644 --- a/examples/effect/platform/src/lib.rs +++ b/examples/effect/platform/src/lib.rs @@ -7,16 +7,16 @@ use std::alloc::Layout; use std::time::SystemTime; extern "C" { - #[link_name = "Main_main_1_exposed"] + #[link_name = "roc__main_1_exposed"] fn roc_main(output: *mut u8) -> (); - #[link_name = "Main_main_1_size"] + #[link_name = "roc__main_1_size"] fn roc_main_size() -> i64; - #[link_name = "Main_main_1_Fx_caller"] + #[link_name = "roc__main_1_Fx_caller"] fn call_Fx(function_pointer: *const u8, closure_data: *const u8, output: *mut u8) -> (); - #[link_name = "Main_main_1_Fx_size"] + #[link_name = "roc__main_1_Fx_size"] fn size_Fx() -> i64; } @@ -60,10 +60,10 @@ unsafe fn call_the_closure(function_pointer: *const u8, closure_data_ptr: *const buffer as *mut u8, ); - let output = &*(buffer as *mut RocCallResult); + let output = &*(buffer as *mut RocCallResult<()>); match output.into() { - Ok(v) => v, + Ok(_) => 0, Err(e) => panic!("failed with {}", e), } })