Preheat the oven to 190C/170C fan/Gas Mark 5. Grease a medium baking dish with a little butter.
Layer the sliced potatoes, carrots and onion in the baking dish, alternating the layers and finishing with a layer of potatoes on top.
Melt the butter in a saucepan over a medium heat, then stir in the flour to make a roux. Cook for 1 minute, stirring constantly.
Gradually whisk in the milk, a little at a time, until you have a smooth sauce. Simmer for 3-4 minutes until it thickens enough to coat the back of a spoon.
Remove from the heat and stir in three quarters of the grated cheese, the mustard, salt, pepper and thyme. Stir until the cheese has melted.
Pour the cheese sauce evenly over the layered vegetables. Sprinkle the remaining cheese on top.
Cover with foil and bake for 30 minutes, then remove the foil and bake for a further 15 minutes until the top is golden and bubbling. Let it stand for 5 minutes before serving.