4.6.1 Thunks

https://github.com/eu81273/jsfiddle-console

by dimitrs_papadimitriou

HTML

<script src="https://rawgit.com/eu81273/jsfiddle-console/master/console.js"></script>
<div id="container">sample text</div>

JavaScript

Object.prototype.toIO = function () { return IO(() => this); }
 
 var IO = fn => ({
    map: f => IO(() => f(fn())), 
    run: () => fn(), 
  })


var getJqueryElementIO =  $("#container").toIO ();

var title = getJqueryElementIO
.map(x=>x.text())
.map(x=>x.toUpperCase())
.run()
console.log(title)