Created
February 10, 2016 18:26
-
-
Save mrtnbroder/7fe72163c9e35f5500c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // side effects | |
| const http = require('http') | |
| const hostname = '127.0.0.1' | |
| const port = 1337 | |
| http.createServer(httpEffect.serverCallback) | |
| .listen(port, hostname, () => { | |
| console.log(`Server running at http://${hostname}:${port}/`) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
http... listenbinds to a socket, making it unavailable for anyone else. If you try to run the code second time, it will fail, because the global state (the socket 1337) has changed. Even if this code cleaned up after itself and released the socket back, it would still be impure, because the execution depends on the outside environment (HTTP stack, operating system), and not just on the inputs to the code.