Hello everyone,
I have some strange error message when using :ets.fun2ms.
I am trying to filter an ets table based on some time.
def get_obsolete_check_in(time) do
fun = :ets.fun2ms(fn {_, %CheckIn{start_time: start_time}} = check_in when start_time > time ->
check_in
end)
:ets.select(:check_ins, fun)
end
Here is the error message.
** (exit) exited in: :ets.fun2ms(:function, :called, :with, :real, :fun, :should, :be, :transformed, :with, :parse_transform, :or, :called, :with, :a, :fun, :generated, :in, :the, :shell)
** (EXIT) :badarg
(stdlib) ets.erl:580: :ets.fun2ms/1
(next_engine) lib/next_engine/check_in_server.ex:30: NextEngine.CheckInServer.get_obsolete_check_in/0
This also happens with a simple function like
fun = :ets.fun2ms(fn check_in -> check_in end)
:ets.select(:check_ins, fun)
Looking for an answer I found similar problems in Erlang here. And it seems the Erlang solution would be to include…
-include_lib("stdlib/include/ms_transform.hrl").
How does this translate to Elixir?
Thanks for taking time.