<div dir="ltr">Thank you Sean for your response. The problem is, how to tell to dialyzer that `my_db:create(Mod, Vals)'<br>is accepts only Mod's which implements `-behaviour(my_db)'? and not an arbitrary atom?<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-16 17:41 GMT+04:00 Sean Cribbs <span dir="ltr"><<a href="mailto:sean@basho.com" target="_blank">sean@basho.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Your example will work if you are implementing some other module which uses my_db as its behavior:<div><br></div><div>-module(db_impl).</div><div>-behaviour(my_db).<br></div><div>-export([table/0]).<br></div>
<div><br></div><div>table -> ["hello, world"].</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Wed, Jul 16, 2014 at 7:56 AM, Daniil Churikov <span dir="ltr"><<a href="mailto:ddosia@gmail.com" target="_blank">ddosia@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">%% I apologize if you get this message second time, but initially I posted it through google-groups<br>
%% interface and discovered that it is not replicated to this mailing list.<br>
<br>Is there any way to write a spec for dialyzer that will tell that I expect module of certain behaviour?<br>
<br>Simplified example:<br><br>-module(my_db)<br><br>-callback table() -> iolist().<br><br>%% Instead of `Mod :: atom()' I want something that will reflect that only<br>%% modules which implements `my_db' behaviour are allowed.<br>
-spec create(Mod :: atom(), Vals :: [iolist(), ...]) -> iolist().<br>create(Mod, Vals) -><br> Table = Mod:table(),<br> ["INSERT INTO ", Table, " VALUES (", string:join(Vals, ", "), ");"].<br>
</div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Sean Cribbs <<a href="mailto:sean@basho.com" target="_blank">sean@basho.com</a>><div>Software Engineer</div>
<div>Basho Technologies, Inc.</div><div><a href="http://basho.com/" target="_blank">http://basho.com/</a></div>
</font></span></div>
</blockquote></div><br></div>