Get function name, module and arity from function capture

That’s not possible. Because you can’t turn a function value back to MFA, just like you can’t turn a value back to the variable name.

You can store the function value itself though:

binary = :erlang.term_to_binary(&MyModule.my_function/0)
# store in db
fun = :erlang.binary_to_term(binary)
fun.()

However, as I mentioned above, that’s a big foot gun.