If I define a function in a Gleam module, it can't be referred to without being invoked unless it is public. For example:
// hello_world.gleam
import gleam/string
fn hello(to whom: String) -> String {
string.append(to: "Hello ", suffix: whom)
}
pub fn hello_world() -> String {
let greeting = hello
greeting("world")
}
generates the following Erlang code:
-module(hello_world).
-compile(no_auto_import).
-export([hello_world/0]).
hello(Whom) ->
gleam@string:append(<<"Hello ">>, Whom).
hello_world() ->
Greeting = fun hello_world:hello/1,
Greeting(<<"world">>).
This will produce a runtime error when executed because the hello/1 function is qualified by the current module name, which means that it needs to be exported. If I change it to fun hello/1, everything works as expected!
Thanks for the report! This bug has been fixed in https://github.com/gleam-lang/gleam/commit/2fa6a54fd739705c2cccceb62bfdd4371b7dd073.
I'll release a new version with this fix tomorrow. 馃憤
Just released a new version, new binaries will be ready once CI has finished :)