Preheat the oven to 200°C / 400°F / Gas mark 6.
Grease and line a shallow flan tin.
Use a medium sized pan and put the spices, coconut, sugar and 150ml of water and cook over a low heat for about 5 minutes, stirring frequently being careful not to let it catch.
Set aside to cool.
Onto a lightly floured work surface, unroll the pastry and line the tin leaving a slight overhang.
Layer greaseproof paper on top of the pastry and add baking beans.
Bake for 15 minutes
Remove the paper and the beans.
Bake the pastry for 5 minutes further so the pastry on the base of the tin is just cooked, but not brown.
Trim away any excess pastry with a sharp knife.
Beat the egg and the melted butter into the cooled coconut mixture, then spoon onto the pastry and smooth the top evenly.
Bake for 25 minutes, in the last 5 minutes top with the reserved coconut until the pastry is golden and the coconut topping is a golden colour.
Serve in slices.