anchor.diff:      Encoders = make_top_encoders(TaggedElems),
       Printer = make_printer(TaggedElems),
       NewAST = Decoders ++ Encoders ++ Printer ++ Forms ++ AST,
  -    NewRecordsAST = [RecAST || {_, RecAST} <- lists:ukeysort(1, RecordsAST)],
  +    Types = get_types(TaggedElems),
  +    Records = make_records(Types),
       Exports = erl_syntax:attribute(
                   erl_syntax:atom("export"),
                   [erl_syntax:list(
  
positive.code:         end,
      DecAST = make_elem_dec_fun(Elem, Tag, AllElems),
      EncAST = make_elem_enc_fun(Elem, Tag, AllElems),
      NewRecords = make_record(Elem) ++ NewState#state.records,
      NewState#state{ast = DecAST ++ EncAST ++ AttrAST ++
                         CDataAST ++ NewState#state.ast,
                     records = NewRecords}.
  
  %% Replace in `Term' every label found in `Labels'
  %% with the corresponding value.
  
negative.code:         ok ->
              file:write_file(
                filename:join([DirName, ModName ++ ".hrl"]),
                [erl_prettypr:format(Hdr),
                 io_lib:nl(),
                 string:join(Records, io_lib:nl() ++ io_lib:nl()),
                 io_lib:nl()]);
          Err ->
              Err
      end.
  
  make_records(Types) ->
      D = dict:from_list(
            lists:flatmap(
              fun({_, {record, RecName, _}}) ->
                      [{{record, RecName}, [{0, []}]}];
                 (_) ->
                      []
              end, Types)),
      {Strings, _} = lists:foldr(
                       fun({_, {record, RecName, _} = R}, {Res, Seen}) ->
                               case lists:member(RecName, Seen) of
                                   false ->
                                       {[record_to_string(R, D)|Res],
                                        [RecName|Seen]};
                                   true ->
                                       {Res, Seen}
                               end;
                          (_, Acc) ->
                               Acc
                       end, {[], []}, Types),
      Strings.
  
  atom_to_string(Atom) ->
      erl_syntax:atom_literal(abstract(Atom)).
  
  record_to_string({record, RecName, RecFields}, RecDict) ->
      Prefix = "-record(" ++ atom_to_string(RecName) ++ ", {",
      Sep = "," ++ io_lib:nl() ++ lists:duplicate(length(Prefix), $ ),
      Fs = lists:map(
             fun({FName, {FType, undefined}}) ->
                     [atom_to_string(FName), " :: ",
                      erl_types:t_to_string(FType, RecDict)];
                ({FName, {FType, Default}}) ->
                     Type = erl_types:t_sup(
                              [erl_types:t_from_term(Default),
                               FType]),
                     [atom_to_string(FName), " = ",
                      io_lib:fwrite("~w", [Default]),
                      " :: ",
                      erl_types:t_to_string(Type, RecDict)]
             end, RecFields),
      [Prefix, string:join(Fs, Sep), "})."].
  
  header(FileName) ->
      erl_syntax:comment(
  