https://rqriley.com/fiberglass-over-foam/
Robert Q. Riley describes using polyurethane foam - which has a very fine grain and is not melted by standard polyester fibreglass resin. Polyurethane foam used to be readily available in insulation supply companies - I'm not sure if it still is.
Polystyrene foam is much more coarse and doesn't cut or sand in the same way. You can use a different, more expensive fibreglass resin (epoxy) to avoid melting polystyrene.