Erlang pattern matching excersise
I see one possible mistake in your code: you do not check if a key already exists before writting a new {Key,Value} pair. This may be intentional, but in this case I think that the read(Key,Db) should return a list of value rather than a single value.

Looking at pattern matching I think that you can simplify the code like this:

read(_Key,{db,[]})-&gt; {error,no_instance};
read(Key,{db,[{Key,CurValue}|_Data]}) -&gt; {ok,CurValue};
% the pattern maching can be done directly, no need to use when.
% I propose to return a tuple {ok,Value} to be consistent with the previous case
% so it will be possible to use pattern matching when using the result of read/2,
% even if the value returned is {error,no_instance}!
read(Key,{db,[_Pair|Data]}) -&gt; read(Key,{db,Data}).
% don't need to create 2 variables

match(Element,Db) -&gt; match(Element,Db,[]).
% transform the function to be tail recursive

match(_Element,{db,[]},R)-&gt;R;
match(Element,{db,[{CurKey,Element}|Data],R}) -&gt; match(Element,{db,Data},[CurKey|R]);
% the pattern maching can be done directly, no need to use when.
match(Element,{db,[_Pair|Data]},R) -&gt; match(Element,{db,Data},R).
% don't need to create 2 variables