Add egg yolks and sugar to a bowl and mix well.
Add flour and mix until well combined.
Heat the milk in a saucepan.
Gradually add the warm milk to the egg mixture, mixing as you go.
Once fully combined, transfer everything back to the saucepan and cook over low heat, stirring constantly.
When the mixture thickens, remove from the heat.
Add butter and vanilla extract, mix well, and let cool.