3 ms·
Callbacks are fine, if you treat them as monads and only use them for notification purposes. In liveScript do error,output <- fs.readFile "helloWorld.txt"
by wrong_variable 10y ago
Callbacks are fine, if you treat them as monads and only use them for notification purposes.
In liveScript
do
error,output <- fs.readFile "helloWorld.txt"
console.log output.toString() # => "hello world from txt file"
you can combine that with co-routines to create really powerful abstractions, without the massive memory footprint of promises.
- adrusi 10y agoTreating callbacks as monads is literally the definition of promises. If that code does the same thing it did in 2011 when I last looked at livescript, that's not treating callbacks as monads, thats just borrowing a syntax that Haskell uses for monads and using it for callbacks.
- spriggan3 10y ago> In liveScript i.e. use a different language because callbacks in javascript suck ? I prefer promises thank you. And promises ARE monads. No need for liveScript.