Skip to content

Instantly share code, notes, and snippets.

@amir343
Created June 28, 2016 09:52
Show Gist options
  • Save amir343/ec66d516df7c6c498781f3678f27bca4 to your computer and use it in GitHub Desktop.
Save amir343/ec66d516df7c6c498781f3678f27bca4 to your computer and use it in GitHub Desktop.
-module(test).
-export([ myfunc/1
, myfunc/2
]).
%%Type alias:
type mywtf :: wtf(string, integer, atom).
%%Type constructor:
type wtf(A, B, C) :: {A, B, C} | {[A], [B], [C]} | (C -> A).
type generic_list(A, B) :: [{A, B}].
type fuzzy :: ok | error.
type error :: atom.
type ok :: atom.
myfun :: [A], (A -> B) -> [atom].
myfun(_A, _B) ->
[ok].
myfun :: mywtf -> atom.
myfun({_A, _B, _C}) ->
ok.
myfunc :: (ok -> atom) -> (A -> [A]).
myfunc(F) ->
Atom :: (ok -> atom) = F,
SomeRandomVar :: fuzzy = case F(amir) of
true -> ok;
false -> error
end,
io:format("~p: ~p~n", [Atom, SomeRandomVar]),
fun(A) -> [A] end.
myfunc :: (M, I) -> (atom -> [atom]).
myfunc(_, _) ->
ok.
map :: (A -> B), [A] -> [B].
map(F, L) ->
lists:map(F, L).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment