8000 Types in exported functions by elbrujohalcon · Pull Request #32 · inaka/erlang_guidelines · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Types in exported functions #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

elbrujohalcon
Copy link
Member

rule

All custom data types used in exported functions should be defined with Erlang type declarations and exported from the module

%% bad
-spec exported_function({integer(), string()}) -> {ok, {binary(), binary()}}.

%% good
-type your_type() :: {integer(), string()}.
-opaque my_type() :: {binary(), binary()}.
-export_type([your_type/0, my_type/0]).
-spec exported_function(your_type()) -> {ok, my_type()}.
reasoning

It helps with function documentation and, with opaque types we ensure encapsulation.

@elbrujohalcon
Copy link
Member Author

I left this rule as a guideline because sometimes small tuples are fine. I guess it's up to the reviewer to decide when this rule should be enforced or not.

@elbrujohalcon elbrujohalcon force-pushed the elbrujohalcon.32.types_in_exported_functions branch from 4a9d753 to 39667ba Compare December 30, 2014 16:31
@HernanRivasAcosta
Copy link
Member

Unfortunately it needs a little rebasing, I think it has to do with you fixing Move stuff to independent applications here.

@elbrujohalcon elbrujohalcon force-pushed the elbrujohalcon.32.types_in_exported_functions branch from 39667ba to 6dbab12 Compare December 30, 2014 17:32
@elbrujohalcon
Copy link
Member Author

@HernanRivasAcosta rebased

@HernanRivasAcosta
Copy link
Member

It still says I can't merge it :(

@elbrujohalcon elbrujohalcon force-pushed the elbrujohalcon.32.types_in_exported_functions branch from 6dbab12 to f3ee097 Compare December 30, 2014 17:41
@elbrujohalcon
Copy link
Member Author

not anymore, @HernanRivasAcosta :trollface:

HernanRivasAcosta added a commit that referenced this pull request Dec 30, 2014
@HernanRivasAcosta HernanRivasAcosta merged commit b54b625 into master Dec 30, 2014
@elbrujohalcon elbrujohalcon deleted the elbrujohalcon.32.types_in_exported_functions branch December 30, 2014 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0