4.1 The Identity Functor

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

by dimitrs_papadimitriou

HTML

<script src="https://rawgit.com/eu81273/jsfiddle-console/master/console.js"></script>

JavaScript

var Id = v => ({
   v: v,
   map: f => Id(f(v)),
   bind: f => f(v),
   matchWith: alg => alg(v)
 });

 Id(5).matchWith(console.log) //5

 console.log(Id(5).v) // Instead of this