Created
September 13, 2016 19:22
-
-
Save jamhed/6b841ff9eba844cf420276b00eb932c5 to your computer and use it in GitHub Desktop.
dia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(dia). | |
| -export_type([uid/0, gid/0]). | |
| -export([uid/0, uid/1, gid/0, gid/1]). | |
| -export([parse_uid/1, do_weird_thing/2, user_uid/1]). | |
| -type uid() :: {uid}. | |
| -type gid() :: {gid}. | |
| -record(user, { | |
| uid = dia:uid() :: uid(), | |
| gid = dia:gid() :: gid() | |
| }). | |
| % nice defaults for records | |
| -spec uid() -> uid(). | |
| uid() -> 0. | |
| -spec uid(T :: uid()) -> integer(); (T :: integer()) -> uid(). | |
| uid(T) -> T. | |
| % nice defaults for records | |
| -spec gid() -> gid(). | |
| gid() -> 0. | |
| -spec gid(T :: gid()) -> integer(); (T :: integer()) -> gid(). | |
| gid(T) -> T. | |
| %% examples | |
| -spec parse_uid(V::integer()) -> uid(). | |
| parse_uid(V) -> dia:uid(V+10). | |
| -spec do_weird_thing(Uid :: uid(), Gid :: gid()) -> integer(). | |
| do_weird_thing(Uid, Gid) -> | |
| dia:uid(Uid) + dia:gid(Gid). | |
| -spec user_uid(#user{}) -> uid(). | |
| user_uid(#user{uid=Uid}) -> uid(Uid). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment