Skip to content

Instantly share code, notes, and snippets.

@exterm
Last active December 15, 2015 02:49
Show Gist options
  • Save exterm/5189682 to your computer and use it in GitHub Desktop.
Save exterm/5189682 to your computer and use it in GitHub Desktop.
Interesting example for multi-clause type spec in erlang dialyzer.
%% multi clause function type spec
-spec plus(integer(), float()) -> float();
(float(), integer()) -> float();
(float(), float()) -> float();
(integer(), integer()) -> integer().
plus(A,B) ->
A + B.
testp() ->
{plus(1,2), plus(1.0,2.0), plus(1,2.0), plus(1.0,2)}.
%% types inferred by dialyzer:
-spec testp() -> {integer(),float(),float(),float()}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment