Put the haricot beans to cook while you prepare the rest of the soup. Add some salt only half-way through their cooking.
Colour the onion in the fat in a large casserole or pan. When the onion is golden, stir in the sugar, then add the pumpkin and reduce the heat so that the flesh will soften without burning. Cover the pan but stir the contents from time to time. When quite soft and alm