Nobody learns from any punishment. The very person who is being punished, he also does not learn what you want him to learn. Yes, he learns something else: he learns how to become a thick-skin.
Once a person goes into prison, prison becomes his home, because there he finds people of a like mind. There he finds his real society. Outside he was a foreigner; there he is in his own world.