Fun references of operators have the wrong arity and module name
leostera opened this issue · comments
Leandro Ostera commented
From #57 by @michallepicki:
This leads to another related issue, currently:
Lists.foldl ( + ) 1 [1; 2; 3]
generates
lists:foldl(fun '+'/0, 1, [1 | [2 | [3 | []]]])
where it lacks the erlang: prefix and the arity is wrong. Not sure if this is something that should be supported right now or not.
Michał Łępicki commented
Michał Łępicki commented
This may or may not be related, fun references of regular functions (not operators) cannot be used this way:
let print thing = Io.format "~0tp~n" [ thing ]
let main _ =
let transforms = [ Binary.first; Binary.last ] in
print (Lists.map (fun g -> g "Hello World") transforms)
results in
% Source code generated with Caramel.
-module(main).
-export([main/1]).
-export([print/1]).
-spec print(_) -> ok.
print(Thing) -> io:format(<<"~0tp~n">>, [Thing | []]).
-spec main(_) -> ok.
main(_) ->
Transforms = [binary:first | [binary:last | []]],
print(lists:map(fun
(G) -> G(<<"Hello World">>)
end, Transforms)).
fun
and the /arity
is missing