Skip to content

Instantly share code, notes, and snippets.

View dpoindexter's full-sized avatar

Daniel Poindexter dpoindexter

  • Indeed
  • Austin, TX
View GitHub Profile
@yelouafi
yelouafi / adt.js
Created April 24, 2015 11:31
Algebraic Data Types in javascript (see http://tech.pro/blog/6885/javascript-and-type-thinking)
function eachKey(obj, f) {
for(var key in obj) {
if( obj.hasOwnProperty(key) )
f(key, obj[key]);
}
}
function adtcase (base, proto, key) {
return (...args) => {
var inst = new base();