lexmag / elixir-style-guide

An opinionated Elixir style guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to split long function specs?

uohzxela opened this issue · comments

Let's say I have a very long function spec:

@callback handle_call(request :: term, state :: term) :: {:ok, reply, new_state} | {:ok, reply, new_state, :hibernate} | {:remove_handler, reply}

How do we split this?

I do this

@callback handle_call(request :: term, state :: term) ::
          {:ok, reply, new_state} |
          {:ok, reply, new_state, :hibernate} |
          {:remove_handler, reply}

@lexmag Is this style rule for @callback, as well as @spec, deserving of mention in the guide? I'm sure it will keep coming up.