[erlang-questions] Module language for Dialyzer?

Pierre Fenoll pierrefenoll@REDACTED
Fri Oct 4 07:21:17 CEST 2013


A module spec can be useful to throw compile-time warnings when implementing generic handlers. 
(A generic handler being a collection of functions calling specific functions from another module.)

Though, a "module signature" already exists (-callback used in pair with -behavior), currently there is no way to check if the other module implements the required functions. 
I think it would be a great addition. 

> On 4 oct. 2013, at 03:48, Siraaj Khandkar <siraaj@REDACTED> wrote:
> 
> What are the theoretical problems (if any) with an idea of extending Dialyzer with a module language to express composable interfaces in the spirit of SML?
> 
> Something along the line of:
> 
> dict.esig:
>    -signature(dict) ::
>    sig
>        -type t(K, V) :: opaque().
>        -fun new() -> t(K, V).
>        -fun add(t(K, V), K, V) -> t(K, V).
>        -fun find(t(K, V), K) -> none | {some, V}.
>        ...
>    end.
> 
> stringable.esig:
>    -signature(stringable) ::
>    sig
>        -type t() :: opaque().
>        -fun to_string(t()) -> string().
>        -fun of_string(string()) -> t().
>        ...
>    end.
> 
> my_serializable_dict.erl:
>    -module(my_serializable_dict).
>    -implements([dict, stringable]).
>    ...
> 
> 
> Syntax is not the point of this, so don't get hung-up on it for the purpose of this question - I'm making it up as I type :)
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list