When David's son from Bathsheba died David stopped mourning and got up and ate, stating that nothing could be done for his son now:
[21] Then his servants said to him, “What is this thing that you have done? You fasted and wept for the child while he was alive; but when the child died, you arose and ate food.” [22] He said, “While the child was still alive, I fasted and wept, for I said, ‘Who knows whether the LORD will be gracious to me, that the child may live?’ [23] But now he is dead. Why should I fast? Can I bring him back again? I shall go to him, but he will not return to me.” (2 Samuel 12:21-23 ESV)
Latter in the same book when David hears that his sons (who was trying to take his throne) is dead he grieved:
[33] And the king was deeply moved and went up to the chamber over the gate and wept. And as he went, he said, “O my son Absalom, my son, my son Absalom! Would I had died instead of you, O Absalom, my son, my son!” (2 Samuel 18:33 ESV)
David was rebuked for mourning (2 Sam 19ff), but did David not grieve for his baby son as he knew the baby would be in heaven (2 Sam 12:23b) and that Absalom wouldn't be? If this is correct, can this reasoning be applied to all babies who die?