10 karma · joined Feb 27, 2014 (12y ago) · 15 submissions
comment 12y ago · link · parent
comment 12y ago · link · parent
Learning Haskell is easier with a strong functional programming background; sadly CS students don't learn much about FP, so having lots of experience in CS and compilers won't necessarily put you in a better position than somebody who has no formal background in CS but lots of programming experience.
A math background on the other hand should help you. Learn about how category theory is applied in Haskell, and you're already half way there. Monads are just a piece of the puzzle.
I do agree with your last three points. I haven't used Haskell in production, so my experience in "real world Haskell" is limited, but it has helped me immensely in my daily work with other languages. Haskell forever changes the way you think and approach problems, just like Vim changes the way you write and edit code; it will make you a better programmer.
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
var multiply = curry(function(x, y){
return x * y;
});
var add = curry(function(x, y){
return x + y;
});
var Calc = (function(){
function Calc(x){
this.x = x;
}
Calc.prototype.map = function(f){
this.x = f(this.x);
return this;
};
return Calc;
}());
new Calc(2).map(compose(add(2), multiply(4)));
// or
new Calc(2).map(multiply(4)).map(add(2));comment 12y ago · link · parent
function getURLParameters(url) {
var res = {},
re = /[?&]([^?&]+)=([^?&]+)/g;
url.replace(re, function(_,k,v) {
res[k] = v;
});
return res;
}
Then use it like "getURLParameters(window.location)".Also just a tip in general, if you're up for some more constructive criticism I'll rewrite your "hasclass" function following conventions. So it goes from this:
function hasclass (el, className) {
if (el.classList)
return el.classList.contains(className);
else
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
To this: function hasClass(el, className) {
if (el.classList) {
return el.classList.contains(className);
}
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
Notice the camel casing in "hasClass", the braces around "if", and the early return.comment 12y ago · link · parent