[erlang-questions] Type specifications for modules implementing a specific behaviour
Sölvi Páll Ásgeirsson
solvip@REDACTED
Mon Dec 19 16:31:34 CET 2016
Hi
(sorry if this is a duplicate, but I sent this message to the list
last week, before subscribing to it, cannot find it anywhere and
assumed it went to the bitbucket)
I've searched, but I haven't found anything and I'm afraid of what I'm
asking is impossible, but I thought I'd ask here as well.
Is there a way for us to say that a type spec is describing a module
that should implement a specific behaviour?
That is, I want to do something like the following:
-module(foo).
-callback foo(bar) -> quux.
Then I'll have a concrete implementation of this:
-module(bar).
-behaviour(foo).
foo(bar) -> quux.
In the third module, I'd like to spec a record so that I can state
that a certain field of the record
should contain an atom which is the name of a module implementing a behaviour:
-module(quux).
-record(state, { callback_mod = bar :: behaviour(foo) }).
I'd then of course like Dialyzer to tell me if something is wrong.
Can we do something like this? If not, would it be extremely
difficult to add support for this? Where could I start?
Thanks alot
Sölvi Páll Ásgeirsson
More information about the erlang-questions
mailing list