What is the effect of cannabis on your sleep?

How does cannabis affect your sleep? Why do people have nightmares after quitting weed? And what effect does cannabis have when you use it when you have had little sleep? Read that in the article Cannabis makes you sleepy at high doses, but do you also get into REM sleep?