My knowledge says coffee is uncountable unless it's used in such a context like 'a cup of coffee' or 'a blend of Argentinian and Brazilian coffees' which are one of the best delicious things in the world. However, I encountered the first sentence below and found the second one later.
I stopped to buy a coffee this morning from the BBC
A coffee can make you forgetful again from the BBC
Luckily, it's explained on the usingenglish.com forums:
The phrase "a coffee" is sometimes used as shorthand for "a cup of coffee".
But, as a double-checker I want to ask you whether it's correct to write 'a coffee' to express 'a cup of coffee' and if it is correct in which type of writing is it OK to use (plain writing, academic writing, informal writing, etc.)?