Another way to say "A hat shades you from the sun." is "To shade oneself from the sun, wear a hat."