Preheat the oven to 200 C / Fan 180/ Gas 6. Rub each potato in a little oil and coarse sea salt. Bake on a rack in the middle of the oven for about 50 minutes, until the flesh is cooked and the skins are crisp.
Meanwhile make a white sauce. Melt the butter in a pan over a moderate heat then add the flour. Mix well with a wooden spoon and cook for about 2 minutes until the mixture starts to turn frothy.
Mix in the milk, a little at a time, until fully incorporated then bring to the boil. Reduce the heat and cook for about 5 minutes until thickened and smooth.
Season with salt and pepper to taste, remove from the heat and beat in the egg yolks. Cover and set aside,
Cut the baked potatoes in half and use a spoon to scoop out the flesh, making sure you leave the skins unbroken. Roughly chop the potato on a chopping board and place in a mixing bowl.
Add the shallot ( if using),the ham, cheese and about three quarters of the white sauce. Mix well.
Using a spoon carefully spoon the mixture back into the potato skins until it is all used up. Spoon over the remaining sauce and place on a baking sheet.
Return to the oven and bake for 10-15 minutes until golden and beginning to bubble at the edges. Remove from the oven and serve with a green salad and perhaps some cornichons.