Monday, October 5, 2009

How to do Namespaces in JavaScript

I just found a nice suggestion about how to do namespacing in JavaScript. In case it goes down or something, this is the gist:

var DED = function() {
    var private_var;
    function private_method() {
        // do stuff here
    }
    return {
        method_1 : function() {
            // do stuff here
        },
        method_2 : function() {
            // do stuff here
        }
    };
}();

Saturday, October 3, 2009

Dr. Seuss on Parser Monads

A Parser for Things / is a function from Strings / to Lists of Pairs / of Things and Strings!
type Parser a = String -> [(a,String)]

A Parser for Things
is a function from Strings
to Lists of Pairs
of Things and Strings!