anchor.diff:  decode_type('REGISTER') -> register;
   decode_type('FLAG')     -> flag;
   decode_type('MAP')      -> map.
  +
  +%% @doc Encodes an atom type into the PB message equivalent, using the
  +%% pass mappings to convert module names into shortnames.
  +-spec encode_type(atom(), type_mappings()) -> atom().
  +encode_type(TypeOrMod, Mods) ->
  +    case lists:keyfind(TypeOrMod, 2, Mods) of
  +        {AtomType, TypeOrMod} ->
  +            encode_type(AtomType);
  +        false ->
  +            encode_type(TypeOrMod)
  +    end.
   
   %% @doc Encodes an atom type name into the PB message equivalent.
   -spec encode_type(atom()) -> atom().
  
positive.code: 
  %% @doc Encodes the result of a fetch request into a FetchResponse message.
  -spec encode_fetch_response(toplevel_type(), toplevel_value(), context()) -> #dtfetchresp{}.
  encode_fetch_response(Type, undefined, _Context) ->
      %% TODO: "Not found" may be undefined, or it may be the
      %% bottom-value of the type, but we need to send something back.
      %% There is also no "context" for a missing datatype, or its
      %% bottom-value.
      #dtfetchresp{type=encode_type(Type)};
  encode_fetch_response(Type, Value, Context) ->
      Response = #dtfetchresp{context=Context, type=encode_type(Type)},
      case Type of
          counter ->
  
negative.code:         set ->
              Response#dtfetchresp{set_value=Value};
          map ->
              Response#dtfetchresp{map_value=[encode_map_entry(Entry, Mods) || Entry <- Value]}
      end.
  
  %% @doc Decodes a DtOperation message into a datatype-specific operation.
  -spec decode_operation(#dtop{}) -> toplevel_op().
  decode_operation(Op) ->
      decode_operation(Op, []).
  
  -spec decode_operation(#dtop{}, [{embedded_type(), module()}]) -> toplevel_op().
  decode_operation(#dtop{counter_op=#counterop{}=Op}, _) ->
      decode_counter_op(Op);
  decode_operation(#dtop{set_op=#setop{}=Op}, _) ->
      decode_set_op(Op);
  decode_operation(#dtop{map_op=#mapop{op='UPDATE', update_field=Field, field_ops=Ops}}, Mods) ->
      {_,FType} = decode_map_field(Field),
      {update, decode_map_field(Field, Mods), [decode_map_field_op(MOp, FType) || MOp <- Ops]};
  decode_operation(#dtop{map_op=#mapop{op=Op, add_remove_fields=Fields}}, Mods) ->
      {decode_op_type(Op), [ decode_map_field(Field, Mods) || Field <- Fields ]}.
  
  %% @doc Encodes a datatype-specific operation into a DtOperation message.
  -spec encode_operation(toplevel_op(), toplevel_type()) -> #dtop{}.
  