anchor.diff:      pack_map_(Tail, << Acc/binary, (pack(Key))/binary, (pack(Value))/binary>>).
   
   % FIXME: write test for unpack_map/1
  --spec unpack_map_(binary(), non_neg_integer(), [{term(), msgpack_term()}])->
  -    {more, non_neg_integer()} | { any(), binary()}.
  -unpack_map_(Bin,  0,  Acc) when is_binary(Bin) -> {{lists:reverse(Acc)}, Bin};
  -unpack_map_(Bin, Len, Acc) when is_binary(Bin) and is_integer(Len) ->
  +-spec unpack_map_(binary(), non_neg_integer(), [{term(), msgpack_term()}]) ->
  +    {more, non_neg_integer()} | {any(), binary()}.
  +unpack_map_(Bin,  0,  Acc) -> {{lists:reverse(Acc)}, Bin};
  +unpack_map_(Bin, Len, Acc) ->
       case unpack(Bin) of
   	{ more, MoreLen } -> { more, MoreLen+Len-1 };
   	{ Key, Rest } ->
  
positive.code: % ===== internal APIs ===== %
  
  % positive fixnum
  pack_uint_(N) when is_integer( N ) , N < 128 ->
      << 2#0:1, N:7 >>;
  % uint 8
  pack_uint_( N ) when is_integer( N ) andalso N < 256 ->
      << 16#CC:8, N:8 >>;
  
  % uint 16
  pack_uint_( N ) when is_integer( N ) andalso N < 65536 ->
      << 16#CD:8, N:16/big-unsigned-integer-unit:1 >>;
  
  % uint 32
  pack_uint_( N ) when is_integer( N ) andalso N < 16#FFFFFFFF->
      << 16#CE:8, N:32/big-unsigned-integer-unit:1 >>;
  
  % uint 64
  pack_uint_( N ) when is_integer( N )->
      << 16#CF:8, N:64/big-unsigned-integer-unit:1 >>.
  
  % negative fixnum
  pack_int_( N ) when is_integer( N ) , N >= -32->
      << 2#111:3, N:5 >>;
  % int 8
  pack_int_( N ) when is_integer( N ) , N >= -256 ->
      << 16#D0:8, N:8 >>;
  % int 16
  pack_int_( N ) when is_integer( N ), N >= -65536 ->
      << 16#D1:8, N:16/big-signed-integer-unit:1 >>;
  % int 32
  pack_int_( N ) when is_integer( N ), N >= -16#FFFFFFFF ->
      << 16#D2:8, N:32/big-signed-integer-unit:1 >>;
  % int 64
  pack_int_( N ) when is_integer( N )->
      << 16#D3:8, N:64/big-signed-integer-unit:1 >>.
  
  % nil
  pack_nil()->    << 16#C0:8 >>.
  % pack_true / pack_false
  pack_bool(true)->    << 16#C3:8 >>;
  pack_bool(false)->   << 16#C2:8 >>.
  
  % float : erlang's float is always IEEE 754 64bit format.
  %pack_float(F) when is_float(F)->
  %    << 16#CA:8, F:32/big-float-unit:1 >>.
  %    pack_double(F).
  % double
  pack_double(F) when is_float(F)->
      << 16#CB:8, F:64/big-float-unit:1 >>.
  
  % raw bytes
  pack_raw(Bin) when is_binary(Bin)->
      case byte_size(Bin) of
  	Len when Len < 6->
  	    << 2#101:3, Len:5, Bin/binary >>;
  
negative.code: 	    end
      end.
  
  
  -spec unpack_(Payload::binary()) -> {more, pos_integer()} | {msgpack_term(), binary()} | {error, reason()}.
  unpack_(<<16#C0, Rest/binary>>) ->
      {nil, Rest};
  unpack_(<<16#C2, Rest/binary>>) ->
      {false, Rest};
  unpack_(<<16#C3, Rest/binary>>) ->
      {true, Rest};
  
  unpack_(<<16#CA, Return:32/float-unit:1, Rest/binary>>) -> % 32bit float
      {Return, Rest};
  unpack_(<<16#CA, Rest/binary>>) ->
      {more, 4-byte_size(Rest)};
  unpack_(<<16#CB, Return:64/float-unit:1, Rest/binary>>) -> % 64bit float
      {Return, Rest};
  unpack_(<<16#CB, Rest/binary>>) ->
      {more, 8-byte_size(Rest)};
  
  unpack_(<<16#CC, Int:8/unsigned-integer, Rest/binary>>) -> % uint 8
      {Int, Rest};
  unpack_(<<16#CC>>) ->
      {more, 1};
  unpack_(<<16#CD, Int:16/big-unsigned-integer-unit:1, Rest/binary>>) -> % uint 16
      {Int, Rest};
  unpack_(<<16#CD, Rest/binary>>) ->
      {more, 2-byte_size(Rest)};
  unpack_(<<16#CE, Int:32/big-unsigned-integer-unit:1, Rest/binary>>) -> % uint 32
      {Int, Rest};
  unpack_(<<16#CE, Rest/binary>>) ->
      {more, 4-byte_size(Rest)};
  unpack_(<<16#CF, Int:64/big-unsigned-integer-unit:1, Rest/binary>>) -> % uint 64
      {Int, Rest};
  unpack_(<<16#CF, Rest/binary>>) ->
      {more, 8-byte_size(Rest)};
  
  unpack_(<<16#D0, Int:8/signed-integer, Rest/binary>>) -> % int 8
      {Int, Rest};
  unpack_(<<16#D0>>) ->
      {more, 1};
  unpack_(<<16#D1, Int:16/big-signed-integer-unit:1, Rest/binary>>) -> % int 16
      {Int, Rest};
  unpack_(<<16#D1, Rest/binary>>) ->
      {more, 2-byte_size(Rest)};
  unpack_(<<16#D2, Int:32/big-signed-integer-unit:1, Rest/binary>>) -> % int 32
      {Int, Rest};
  unpack_(<<16#D2, Rest/binary>>) ->
      {more, 4-byte_size(Rest)};
  unpack_(<<16#D3, Int:64/big-signed-integer-unit:1, Rest/binary>>) -> % int 64
      {Int, Rest};
  unpack_(<<16#D3, Rest/binary>>) ->
      {more, 8-byte_size(Rest)};
  
  unpack_(<<16#DA, Len:16/unsigned-integer-unit:1, Val:Len/binary, Rest/binary>>) -> % raw 16
      {Val, Rest};
  unpack_(<<16#DA, Rest/binary>>) ->
      {more, 16-byte_size(Rest)};
  unpack_(<<16#DB, Len:32/unsigned-integer-unit:1, Val:Len/binary, Rest/binary>>) -> % raw 32
      {Val, Rest};
  unpack_(<<16#DB, Rest/binary>>) ->
      {more, 32-byte_size(Rest)};
  
  unpack_(<<16#DC, Len:16/big-unsigned-integer-unit:1, Rest/binary>>) -> % array 16
      unpack_array_(Rest, Len, []);
  unpack_(<<16#DC, Rest/binary>>) ->
      {more, 2-byte_size(Rest)};
  unpack_(<<16#DD, Len:32/big-unsigned-integer-unit:1, Rest/binary>>) -> % array 32
      unpack_array_(Rest, Len, []);
  unpack_(<<16#DD, Rest/binary>>) ->
      {more, 4-byte_size(Rest)};
  
  unpack_(<<16#DE, Len:16/big-unsigned-integer-unit:1, Rest/binary>>) -> % map 16
      unpack_map_(Rest, Len, []);
  unpack_(<<16#DE, Rest/binary>>) ->
      {more, 2-byte_size(Rest)};
  unpack_(<<16#DF, Len:32/big-unsigned-integer-unit:1, Rest/binary>>) -> % map 32
      unpack_map_(Rest, Len, []);
  unpack_(<<16#DF, Rest/binary>>) ->
      {more, 4-byte_size(Rest)};
  
  unpack_(<<0:1, Value:7, Rest/binary>>) -> % positive fixnum
      {Value, Rest};
  unpack_(<<2#111:3, Value:5, Rest/binary>>) -> % negative fixnum
      {Value - 2#100000, Rest};
  unpack_(<<2#101:3, Len:5, Value:Len/binary, Rest/binary>>) -> % fixraw
      {Value, Rest};
  unpack_(<<2#101:3, Len:5, Rest/binary>>) ->
      {more, Len-byte_size(Rest)};
  unpack_(<<2#1001:4, Len:4, Rest/binary>>) -> % fixarray
      unpack_array_(Rest, Len, []);
  unpack_(<<2#1000:4, Len:4, Rest/binary>>) -> % fixmap
      unpack_map_(Rest, Len, []);
  
  %unpack_(<<F:8, Rest/binary>>) when F==16#C1; F==16#C4; F==16#C5; F==16#C6; F==16#C7; F==16#C8; F==16#C9; F==16#D5; F==16#D6; F==16#D7; F==16#D8; F==16#D9->
  %    {error, {badarg, <<F, Rest/binary>>}}.
  %unpack_(Other) when is_binary(Bin) ->
  %    {more, 1}.
  unpack_(<<>>) ->
      {more, 1}.
  unpack_(Other) ->
      {error, {badarg, Other}}.
  
  
  % ===== test codes ===== %
  -include_lib("eunit/include/eunit.hrl").
  