[erlang-questions] Overloaded function specifications as types

Kostis Sagonas kostis@REDACTED
Mon Jan 23 11:58:47 CET 2017


On 01/23/2017 11:30 AM, Dániel Szoboszlay wrote:
> Is there a way I can use this overloaded function's type in non-spec
> contexts? Like I want to say bar/1 takes a function as an argument that
> has a spec like foo/1 above.
>
> I can think of the following options, but neither of them is exactly
> what I want:
>
>... <SKIP>
>
> -spec bar(fun((integer()) -> integer()) | fun((atom()) -> atom())) -> ok.
> %% Allows fun erlang:atom_to_list/1, which doesn't work on integers at all.

I'm seriously confused as I do not see anything related to lists here...

Can you elaborate?

Kostis



More information about the erlang-questions mailing list