anchor.diff:           terminate/2, 
            code_change/3]).
   
  +-type chip() :: 1|2.
   
  -%%====================================================================
  -%% Server interface
  -%%====================================================================
  -%% Booting server (and linking to it)
  +-type column() :: [chip()].
  +
  +-type board() ::
  +  {column(), column(), column(), column(), column(), column(), column()}.
  +
  +-type col() :: 1..7.
  +
  +-type from() :: {pid(), _}.
  +
  +-type reason() :: normal | shutdown | {shutdown, term()} | term().
  +
  +-type oldVsn() :: term() | {down, term()}.
  +
  +-record(state, {board::board(), next_chip = 1 :: chip()}).
  +
  +-type state() :: #state{}.
  +
  +-spec start() -> {ok, pid()}.
   start() -> 
       gen_server:start({local, ?MODULE}, ?MODULE, [], []).
   
  -%% Stopping server asynchronously
  +-spec stop(pid()) -> ok.
   stop(Pid) ->
       gen_server:cast(Pid, shutdown).
   
  -%-spec play(pid(), col()) -> won | drawn | next.
  +-spec play(pid(), col()) -> won | drawn | next.
   play(Pid, Col) -> 
     case gen_server:call(Pid, {play, Col}) of
       {ok, Reply} -> Reply;
       {error, Ex} -> throw(Ex)
     end.
   
  -%%====================================================================
  -%% gen_server callbacks
  -%%====================================================================
  +-spec init([]) -> {ok, state()}.
   init([]) ->
  -    %process_flag(trap_exit, true),
       EmptyState = fiar_core:start(),
       {ok, EmptyState}.
   
  -%% Synchronous, possible return values  
  -% {reply,Reply,NewState} 
  -% {reply,Reply,NewState,Timeout}
  -% {reply,Reply,NewState,hibernate}
  -% {noreply,NewState}
  -% {noreply,NewState,Timeout}
  -% {noreply,NewState,hibernate}
  -% {stop,Reason,Reply,NewState} 
  -% {stop,Reason,NewState}
  +-spec handle_call({play, col()}, from(), state()) -> {reply, {ok | error, won | drawn | next}, state()}.
   handle_call({play, Col}, _From, State) ->
  - try
  -    {Reply, NewState} = case fiar_core:play(Col, State) of
  + try {Reply, NewState} = case fiar_core:play(Col, State) of
         {Result, NextState} -> {Result, NextState};
         Result -> {Result, State}
       end,
  
positive.code:         {reply, {error, Ex}, State}
    end.
  
  %% Asynchronous, possible return values
  % {noreply,NewState} 
  % {noreply,NewState,Timeout}
  % {noreply,NewState,hibernate}
  % {stop,Reason,NewState}
  %% normal termination clause
  handle_cast(shutdown, State) ->
      io:format("Generic cast handler: *shutdown* while in '~p'~n",[State]),
      {stop, normal, State};
  %% generic async handler
  handle_cast(Message, State) ->
      io:format("Generic cast handler: '~p' while in '~p'~n",[Message, State]),
      {noreply, State}.
  
  %% Informative calls
  % {noreply,NewState} 
  % {noreply,NewState,Timeout} 
  % {noreply,NewState,hibernate}
  % {stop,Reason,NewState}
  handle_info(Message, State) -> 
      io:format("Generic info handler: '~p' '~p'~n",[Message, State]),
      {noreply, State}.
  
  %% Server termination
  terminate(_Reason, _Server) -> 
      io:format("Generic termination handler: '~p' '~p'~n",[_Reason, _Server]).
  
  
  %% Code change
  code_change(_OldVersion, Server, _Extra) -> {ok, Server}.
    
negative.code: -module(fiar_match).
  -export([start/0, play/2, stop/1]).
  
  -behaviour(gen_server).
      
  -export([init/1,
           handle_call/3, 
           handle_cast/2,
  