[erlang-bugs] dialyzer / typer issue.

][azar <>
Thu Aug 16 14:00:38 CEST 2012


I've some code like this.

-module(test).
-export([test/1]).
          .
-spec my_apply(Arg,fun((Arg) -> Result)) -> Result.
my_apply(Arg,Fun) ->
    Fun(Arg).

-spec my_fun(good) -> ok
      ; (bad) -> error.
my_fun(good) -> ok;
my_fun(bad) -> error.

test(A) ->
    my_apply(A,fun my_fun/1).


And i whan't Dialyzer valid the A param in test/1 function,
but Typer generates this spec:

-spec test(_) -> any().

But valid is

-spec test(good) -> ok
      ; (bad) -> error.

I don't whant to write spec for functions like test/1 each time i use
my_apply/2.
How to help the dialyzer with type inference?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120816/f49683ec/attachment.html>


More information about the erlang-bugs mailing list