I'd argue that if the intention is entirely to rehabilitate (and incapacitate if necessary) then a prison sentence would only incidentally be a punishment.
Don't get me wrong - I don't believe that the US "justice system" is at all concerned with rehabilitation. Giving 2 life sentences to a non violent drug offender is ridiculous.