December 2012
1 post
Monads as I understand them
To be honest, it took me a ton of tutorials - a ton - before I could look you in the eye and say I understand what the hell a monad is. I believe the reason for this is not because they are hard, but because all those tutorials didn’t build upon my basic understanding of functors. Functors are much easier to understand. If you need a refresher read this: ...
Dec 3rd
2 notes
October 2012
0 posts
Tail call optimization on it's way... Who gives a...
I’m going to talk about capturing different recursive patterns in higher order functions and how we are better off with them over explicit recursion anyways. But first, let’s quickly go over what recursion is in javascript and why we might care about it. Recursion in javascript What is recursion? Well, it’s just calling a function from within itself. It is usually used as a...
Oct 1st
July 2012
1 post
I do declare
Brian vs Abstraction Round 1 Martin Fowler once said something to the effect that programming, at it’s finest, should be nothing more than the configuration of abstractions. This made a little bit of my brain leak out my ear the first time I read it. It was a statement that made me question everything I’d written up until that point. It was brilliant! I was going to make...
Jul 22nd
June 2012
2 posts
Functor, I hardly knew her!
I’m here! I’m at that special moment where I just realized why the heck functors matter. At first I knew the types and I knew the ideas, I just didn’t understand why it mattered. I think the root of my misunderstanding was my OO background and confusion about the job of types in the functional realm. I’m gonna write a post about that tomorrow, promise. The big...
Jun 19th
1 note
Silly module tricks
I’d been jealous of a nice haskell feature, as I typically am, and thought I’d try to get as close as I could with javascript, as I typically do. The “must have” feature is the ability to mix in a module globally or qualify it with a name. Suppose we have an Account module with two functions: sayName and User. Here’s the desired behavior: I can mix in all the...
Jun 17th
May 2012
5 posts
2 tags
May 13th
4 tags
Everybody loves monads
I made a monad library for javascript. I’m hosting it here https://github.com/DrBoolean/MonadsJs. **This was a monad library based on the one for clojure since we weren’t using types in js. Since then I’ve updated the library to use objects as types so while the examples here still have the same outcome, they don’t work the same way anymore and the api is different. A...
May 13th
2 notes
4 tags
Partial Application
My dad once told me there are some things in this world that you can live without…until you get them. This is a truism that gets truer for me every year. I think it has something to do with better technology. Take for instance, an iphone or spotify or streaming netflix. In my dad’s case he was talking about a microwave. Generation gap! Anyways, partial application is one of those...
May 13th
4 tags
Tweet Grammer Fixer: OO vs FP
To play with what I’ve been learning, I’m going to make a OO vs Functional comparison. The goal is to clean up tweet grammer. The output should be something like: // Before // "I'm tweeting like an animal but I keep missing punctuation. someone make me a tool.Then I can tweet like a scholar." // After // "I'm tweeting like an animal, but I keep missing punctuation. Someone make me a...
May 13th
1 note
4 tags
Composition
Composition is a fancy name for passing the result of one function as an argument into the next function. If we have some functions like these: add2 = function(number) { return number + 2; } subtract1 = function(number) { return number - 1; } We could do this: addSubtract = function(n) { var addedValue = add2(n); return subtract1(addedValue); } Or We could do...
May 12th