Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use the Fn monoid(semigroup) #1

Open
ghost opened this issue Jan 12, 2017 · 2 comments
Open

can't use the Fn monoid(semigroup) #1

ghost opened this issue Jan 12, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 12, 2017

I'm trying to use your implementation of Fn monoid to concat some functions but it keeps throwing me an error saying concat is not a function...

const Fn = f =>
({
  fold: f,
  concat: o =>
    Fn(x => f(x).concat(o.fold(x))),
  inspect: () => `Fn(${f})`
})

const fn = Fn(x => x + 1)

console.log(fn.concat(Fn(x => x - 1)).fold(3).inspect()) //TypeError: f(...).concat is not a function

i understand that f(x) does not have the concat method because f is not wrapped inside Fn on this context, but what am getting wrong... is this a bug or i am not using it propperly?

@aabrook
Copy link

aabrook commented Jul 16, 2017

You've probably long resolved the issue @MCarvalho but I think the referenced PR will fix the problem you were having.

@DrBoolean
Copy link
Owner

Each Fn should return a monoid

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

No branches or pull requests

2 participants