This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.asyncMap = function (fn, callback) { | |
var that = this, i, count = 0, errors = [], map = []; | |
for (i = 0; i < this.length; i += 1) { | |
(function iter(i) { | |
fn(that[i], function (err, value) { | |
err && errors.push(err); | |
map[i] = value; | |
count += 1; | |
if (count === that.length) { | |
callback(errors.length ? errors : false, map); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data A = A Text | |
data B = B Text A | |
data ActionC t next = InsertC t (t -> next) | |
instance Functor (ActionC t) where | |
fmap f (InsertC a b)= InsertC a (f . b) | |
insertC a = liftF (InsertC a id) | |
proC txt1 txt2 = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Explicitly stating the order of computation `a (b c)` makes this not compile | |
-- While, if we used a C style, order of computation would be explicit by default `a(b(c))` vs `a(b, c)` | |
example1 = a b c | |
where | |
a first second = first ++ second | |
b = "hey" | |
c = " world" | |
-- Explicitly stating `a (b c)` makes this compile | |
example2 = a b c |