anchor.diff:  
   -opaque(state). %% Implementation state
   
  +-opaque(alg_seed).  %% Algorithm dependent state
  +
   %% This depends on the algorithm handler function
  --type alg_state() :: any().
  +-type alg_seed() :: any().
   %% This is the algorithm handler function within this module
   -type alg_handler() :: #alg{}.
   %% Internal state
  --type state() :: {alg_handler(), alg_state()}.
  +-type state() :: {alg_handler(), alg_seed()}.
   
   -type alg() :: as183 | exs64 | exsplus | exs1024 | sfmt | tinymt.
   
  
positive.code: %% API
  %% =====================================================================
  
  %% Return used algorithm
  -spec get_algorithm() -> undefined | alg().
  
  get_algorithm() ->
      case seed_get() of
  	{#alg{type=Alg}, _} -> Alg;
  	_ -> undefined
      end.
  
  -spec get_algorithm(state()) -> alg().
  
  get_algorithm({#alg{type=Alg}, _}) -> Alg.
  
  %%% Note: if a process calls uniform/0 or uniform/1 without setting a seed first,
  %%%       seed/0 is called automatically.
  
negative.code: 
  seed(A1, A2, A3) ->
      Old = seed_get(),
      _ = make_seed(?DEFAULT_ALG_HANDLER, {A1, A2, A3}),
      Old.
  
  
  %% make_seed(Alg) seeds RNG with runtime dependent values
  %% and return the NEW state
  -spec make_seed(alg() | {alg(), alg_seed()}) -> state().
  
  make_seed(Alg) when is_atom(Alg) ->
      make_seed(Alg,
  	      {erlang:phash2([{node(),self()}]),
  	       erlang:monotonic_time(),
  	       erlang:unique_integer()});
  
  %% make_seed({Alg,Seed}) setup RNG with a previously exported seed
  %% and return the NEW state
  make_seed({Alg0, Seed}) ->
      Alg = mk_alg(Alg0),
      _ = seed_put({Alg, Seed}),
      {Alg, Seed}.
  
  %% make_seed/2: seeds RNG with the algorithm and given values
  %% and returns the NEW state.
  
  -spec make_seed(Alg :: alg(), {integer(), integer(), integer()}) ->
  		       state().
  
  make_seed(Alg0, S0 = {_, _, _}) ->
      Alg=#alg{seed=Seed} = mk_alg(Alg0),
      AS = Seed(S0),
      _ = seed_put({Alg, AS}),
      {Alg, AS}.
  
  