So for a while I’ve been working on a maybe monad implementation for JavaScript and have made decent headway, or so I thought. My previous attempts have been decent however they require the use of the new operator which is BAD for memory utilization and allocation. As a point of reference here’s my first go at it.
As you can see its very verbose and uses the this operator with impunity. Great or so I thought until I learned how 'the good parts' of JavaScript. Since learning a better way of writing JavaScript I've been struggling how best to write a maybe monad that will natively 'just work' without having to use new or engineer in other special stuff. I was inspired by the functional elements of JavaScript and using closures and prototype definitions on Function to make it work 'out of the box'. So here we are :)
0 comments:
Post a Comment