Many thanks to my Cambridge colleague Peter Smith, who has shown me a passage in Odifreddi where all this is explained perfectly. As i suspected, it has something to do with cartesian-closed categories...