fantasyland/daggy

Checks fail when stored in variable

edahlseng opened this issue · 2 comments

When attempting to pass a check function into a higher order function to be used as a predicate, I get an error. A minimal reproduction of the error follows:

const Reader = daggy.taggedSum("Reader", {
  Get: []
});
const a = Reader.Get;
const b = Reader.is;
b(a) // Failure here
.../node_modules/daggy/src/daggy.js:109
    return this[TYPE] === type(val);
               ^

TypeError: Cannot read property '@@type' of undefined

As a workaround, I can use an anonymous function that calls the check directly (e.g. x => Reader.is(x), but it would be nice to be able to avoid this, if possible!

Would you like to submit a pull request to fix this? If you're unsure of the correct fix, a pull request containing a failing test case would be a great start.

This issue was addressed in #33. Thanks for the pull request, @joedski!