Skip to content

Commit

Permalink
Support ! in symbols provided to host
Browse files Browse the repository at this point in the history
  • Loading branch information
agu-z committed Oct 16, 2024
1 parent 0d3c483 commit b55c8d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions crates/compiler/mono/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4647,20 +4647,20 @@ impl LayoutId {
// Returns something like "#UserApp_foo_1" when given a symbol that interns to "foo"
// and a LayoutId of 1.
pub fn to_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
let module_string = interns.module_ids.get_name(symbol.module_id()).unwrap();
format!("{}_{}_{}", module_string, ident_string, self.0)
}

// Returns something like "roc__foo_1_exposed" when given a symbol that interns to "foo"
// and a LayoutId of 1.
pub fn to_exposed_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
format!("roc__{}_{}_exposed", ident_string, self.0)
}

pub fn to_exposed_generic_symbol_string(self, symbol: Symbol, interns: &Interns) -> String {
let ident_string = symbol.as_str(interns);
let ident_string = symbol.as_str(interns).trim_end_matches('!');
format!("roc__{}_{}_exposed_generic", ident_string, self.0)
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/cli/effects-platform/main.roc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
platform "effects"
requires {} { main : {} => {} }
requires {} { main! : {} => {} }
exposes []
packages {}
imports []
provides [mainForHost]
provides [mainForHost!]

mainForHost : {} => {}
mainForHost = \{} -> main {}
mainForHost! : {} => {}
mainForHost! = \{} -> main! {}
6 changes: 3 additions & 3 deletions examples/cli/effects.roc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
app [main] { pf: platform "effects-platform/main.roc" }
app [main!] { pf: platform "effects-platform/main.roc" }

import pf.Effect

main : {} => {}
main = \{} ->
main! : {} => {}
main! = \{} ->
line = Effect.getLine! {}

if line == "secret" then
Expand Down

0 comments on commit b55c8d2

Please sign in to comment.