what is the type signature of `Func` in gen_server:start/4?

The OTP docs say the signature for gen_server:start/4 is this:

start_link(ServerName, Module, Args, Options) -> Result
ServerName = {local,Name} | {global,GlobalName}
  | {via,Module,ViaName}
 Name = atom()
 GlobalName = ViaName = term()
Module = atom()
Args = term()
Options = [Option]
 Option = {debug,Dbgs} | {timeout,Time} | {hibernate_after,HibernateAfterTimeout} | {spawn_opt,SOpts}
  Dbgs = [Dbg]
   Dbg = trace | log | statistics | {log_to_file,FileName} | {install,{Func,FuncState}}
  SOpts = [term()]
Result = {ok,Pid} | ignore | {error,Error}
 Pid = pid()
 Error = {already_started,Pid} | term()

What is Func? The docs just say:

This function is useful when a more complex initialization procedure is needed than the gen_server process behavior provides.

So now I know it is useful. But how many arguments does it take? Of what types?

Thanks for help.


  • The Func in that spec is an option for debug, so it has little to do with that doc.

    The doc you have quoted refers to the gen_server:enter_loop function, not to Func.

    Regarding your question, Func is handled with the sys module, like in sys:install/2, and has the following spec:

     dbg_fun() =
        fun((FuncState :: term(),
             Event :: system_event(),
             ProcState :: term()) ->
                done | (NewFuncState :: term()))