This repository was archived by the owner on Aug 6, 2018. It is now read-only.

Description
Am here refering to the chain method in
|
Writer.prototype.chain = function(f) { |
|
return Writer(() => { |
|
const result = this.run(); |
|
const t = f(result._1).run(); |
|
return Tuple2(t._1, result._2.concat(t._2)); |
|
}); |
|
}; |
.
Writer.prototype.chain = function(f) {
return Writer(() => {
const result = this.run(); //1
const t = f(result._1).run(); //2
return Tuple2(t._1, result._2.concat(t._2)); //3
});
};
Am using T, S, R as arbitrary type variables.
Here let the type of result from line 1 is Tuple2(T, Monoid), so result._2 is a Monoid, t is of type Tuple2(S, Monoid), so t._2 is a Monoid, both got by run()ning the monad constructor. In line 3 the 2nd part of the tuple is result._2.concat(t._2), which translates to type Monoid.concat(Monoid). I feel something's not right here, right now am using js Array which kind of is easy in that it doesn't care if I concat an array of an element or the element itself, the result is the same. Is there something amiss here?