diff --git a/hacking_erlang.key b/hacking_erlang.key index 6a8a64a..26ecfe4 100644 Binary files a/hacking_erlang.key and b/hacking_erlang.key differ diff --git a/src/example1.erl b/src/example1.erl index cc6dc53..11ab272 100644 --- a/src/example1.erl +++ b/src/example1.erl @@ -1,4 +1,7 @@ -module(example1). +-compile({parse_transform, print_forms}). -export([foo/0]). -foo() -> "Hello Stockholm!". \ No newline at end of file +foo() -> "Hello Stockholm!". + + diff --git a/src/example2.erl b/src/example2.erl index 3728c5c..49f5bac 100644 --- a/src/example2.erl +++ b/src/example2.erl @@ -1,21 +1,22 @@ -module(example2). --compile({parse_transform, expand_records}). --export([encode_record/1]). - --record(pizza, {size, toppings, price}). - -encode_record(Rec) -> - [RecName|Fields] = tuple_to_list(Rec), - FieldNames = expanded_record_fields(RecName), - lists:zip(FieldNames, Fields). - - -encode_record(Rec) -> - case Rec of - Pizza when is_record(Pizza, pizza) -> - [{size, Pizza#pizza.size}, - {toppings, Pizza#pizza.toppings}, - {price, Pizza#pizza.price}]; - _ -> - exit(wtf_do_i_do_with_this) - end. \ No newline at end of file +% -compile({parse_transform, expand_records}). +% -export([record_to_proplist/1]). +% +% -record(pizza, {size, toppings, price}). +% +% record_to_proplist(Rec) when is_tuple(Rec) -> +% [RecName|Fields] = tuple_to_list(Rec), +% FieldNames = expanded_record_fields(RecName), +% lists:zip(FieldNames, Fields). +% +% +% record_to_proplist(Rec) when is_tuple(Rec) -> +% case Rec of +% Pizza when is_record(Pizza, pizza) -> +% [{size, Pizza#pizza.size}, +% {toppings, Pizza#pizza.toppings}, +% {price, Pizza#pizza.price}]; +% _ -> +% exit(wtf_do_i_do_with_this) +% end. +% diff --git a/src/print_forms.erl b/src/print_forms.erl new file mode 100644 index 0000000..3b0bfe0 --- /dev/null +++ b/src/print_forms.erl @@ -0,0 +1,8 @@ +-module(print_forms). +-export([parse_transform/2]). + +parse_transform(Forms, _Options) -> + io:format("forms: ~p~n", [Forms]), + Forms. + +