Skip to content

Instantly share code, notes, and snippets.

@ympbyc
Last active December 27, 2015 20:09
Show Gist options
  • Save ympbyc/7381755 to your computer and use it in GitHub Desktop.
Save ympbyc/7381755 to your computer and use it in GitHub Desktop.
fs = require 'fs';
readFile = (fname) ->
fs.readFileSync fname, encoding: "utf8"
print = (str) ->
console.log str
null
main = -> [
-> print "Hello, what's your name? "
-> {name: readFile "name.txt"}
(binding) -> print "Nice to meet you #{binding.name}."
]
runIO = (app) ->
app().reduce ((init, f) ->
patch = f init
unless patch then init else
_.conj init, patch), {}
runIO main
## what's the difference to
main = -> ->
print "blah"
name = getLine()
print "blah #{name}"
runIO = (f) -> f()
runIO main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment