Skip to main content
Commonmark migration
Source Link

#Haskell

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 "/"
The main function is supposed to return a concept of doing something. removeDirectoryRecursive "/" returns a concept of wiping your filesystem, but the return function (yes, it is a function), wraps its argument in a dummy concept of returning that value.
So we end up with a concept of returning a concept of wiping your drive. (Yo dawg I herd you like concepts.) The haskell runtime executes the concept returned from main and discards the returned value, which in our case is a concept of wiping your filesystem.

#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 "/"
The main function is supposed to return a concept of doing something. removeDirectoryRecursive "/" returns a concept of wiping your filesystem, but the return function (yes, it is a function), wraps its argument in a dummy concept of returning that value.
So we end up with a concept of returning a concept of wiping your drive. (Yo dawg I herd you like concepts.) The haskell runtime executes the concept returned from main and discards the returned value, which in our case is a concept of wiping your filesystem.

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 "/"
The main function is supposed to return a concept of doing something. removeDirectoryRecursive "/" returns a concept of wiping your filesystem, but the return function (yes, it is a function), wraps its argument in a dummy concept of returning that value.
So we end up with a concept of returning a concept of wiping your drive. (Yo dawg I herd you like concepts.) The haskell runtime executes the concept returned from main and discards the returned value, which in our case is a concept of wiping your filesystem.

deleted 101 characters in body
Source Link
mniip
  • 9.5k
  • 4
  • 31
  • 57

#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.
The main function is expectedsupposed to return a valueconcept of the typedoing something. IOremoveDirectoryRecursive x"/" returns a concept of wiping your filesystem, which contains all actionsbut the program has performed return function (will performyes, remember lazinessit is a function), and then, after executing those actions and passing values between, wraps its argument in a dummy it discards xconcept of returning that value.
What return foo does, is createSo we end up with a dummy action which simply returns the value fooconcept of returning a concept of wiping your drive. So, the directory removal function has(Yo dawg I herd you like concepts.) executed, but it returned an IO action, which when passed toThe haskell runtime executes the return is wrapped once more, and as I already said,concept returned from main would discardand discards the actionreturned value, which in our case is a concept of wiping your filesystem.

#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 type IO x, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discards x.
What return foo does, is create a dummy action which simply returns the value foo. So, the directory removal function has executed, but it returned an IO action, which when passed to return is wrapped once more, and as I already said, main would discard the action.

#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 "/"
The main function is supposed to return a concept of doing something. removeDirectoryRecursive "/" returns a concept of wiping your filesystem, but the return function (yes, it is a function), wraps its argument in a dummy concept of returning that value.
So we end up with a concept of returning a concept of wiping your drive. (Yo dawg I herd you like concepts.) The haskell runtime executes the concept returned from main and discards the returned value, which in our case is a concept of wiping your filesystem.

fix spoilers
Source Link
mniip
  • 9.5k
  • 4
  • 31
  • 57

#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 type IO x, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discards x.
! What return foo does, is create a dummy action which simply returns the value foo. So, the directory removal function has executed, but it returned an IO action, which when passed to return is wrapped once more, and as I already said, main would discard the action.

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 type IO x, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discards x.
What return foo does, is create a dummy action which simply returns the value foo. So, the directory removal function has executed, but it returned an IO action, which when passed to return is wrapped once more, and as I already said, main would discard the action.

#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 type IO x, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discards x.
! What return foo does, is create a dummy action which simply returns the value foo. So, the directory removal function has executed, but it returned an IO action, which when passed to return is wrapped once more, and as I already said, main would discard the action.

#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 type IO x, which contains all actions the program has performed (will perform, remember laziness), and then, after executing those actions and passing values between, it discards x.
What return foo does, is create a dummy action which simply returns the value foo. So, the directory removal function has executed, but it returned an IO action, which when passed to return is wrapped once more, and as I already said, main would discard the action.

added 512 characters in body
Source Link
mniip
  • 9.5k
  • 4
  • 31
  • 57
Loading
added 15 characters in body
Source Link
mniip
  • 9.5k
  • 4
  • 31
  • 57
Loading
Source Link
mniip
  • 9.5k
  • 4
  • 31
  • 57
Loading