Skip to content
This repository has been archived by the owner on Aug 6, 2018. It is now read-only.

Confusion with the signature of the function used in chain #5

Open
paulvictor opened this issue Mar 1, 2016 · 0 comments
Open

Confusion with the signature of the function used in chain #5

paulvictor opened this issue Mar 1, 2016 · 0 comments

Comments

@paulvictor
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant