The bar construction and abelian $H$-spaces