#Haskell
Check this manual page, removeDirectoryRecursive
deletes a directory with all of its contents!
import System.Directory
main = return (removeDirectoryRecursive "/")
! The correct code would be
main = removeDirectoryRecursive "/"
! In haskell as functions are pure, they cannot leave any side-effects. So for that purpose, the IO monad was invented.
!main
function is expected to return a value of the typeIO x
, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discardsx
.
! Whatreturn foo
does, is create a dummy action which simply returns the valuefoo
. So, the directory removal function has executed, but it returned an IO action, which when passed toreturn
is wrapped once more, and as I already said,main
would discard the action.