Handle singleton records in erlang_to_fate #27
+22
-7
@@ -944,15 +944,30 @@ fate_to_erlang({O, N, {unknown_type, _}}, Data) ->
|
||||
io:format(Message, [O, N, Data])
|
||||
end,
|
||||
{ok, Data};
|
||||
fate_to_erlang({O, N, _}, Data) ->
|
||||
case N of
|
||||
already_normalized ->
|
||||
io:format("Warning: Unimplemented type ~p.~nUsing term as is:~n~p~n", [O, Data]);
|
||||
_ ->
|
||||
io:format("Warning: Unimplemented type ~p (i.e. ~p).~nUsing term as is:~n~p~n", [O, N, Data])
|
||||
end,
|
||||
fate_to_erlang(Type, Data) ->
|
||||
TypeStr = type_to_iolist(Type),
|
||||
io:format("Warning: Could not coerce term into ~s. Using term as is: ~p~n", [TypeStr, Data]),
|
||||
{ok, Data}.
|
||||
|
||||
type_to_iolist({O, already_normalized, S}) ->
|
||||
% Already normalized. Example output:
|
||||
% type {map, [string, integer]}
|
||||
opaque_type_to_iolist(O, S);
|
||||
type_to_iolist({O, N, S}) ->
|
||||
% Type alias. Print the alias, and then print the normalized version in
|
||||
% parentheses. Example output:
|
||||
% type "my_alias" (i.e. record type {"my_record_type", [integer]})
|
||||
io_lib:format("type ~p (i.e. ~s)", [O, opaque_type_to_iolist(N, S)]).
|
||||
|
||||
opaque_type_to_iolist(N, {record, _}) ->
|
||||
% N is the name of a record definition.
|
||||
io_lib:format("record type ~p", [N]);
|
||||
opaque_type_to_iolist(N, {variant, _}) ->
|
||||
% N is the name of a variant definition.
|
||||
io_lib:format("variant type ~p", [N]);
|
||||
opaque_type_to_iolist(N, _) ->
|
||||
% N is some other constructive type.
|
||||
io_lib:format("type ~p", [N]).
|
||||
|
||||
|
||||
%%% AACI Getters
|
||||
|
||||
Reference in New Issue
Block a user