What Category theory object makes Array in JavaScript chainable?

36 Views Asked by At

I don't know much about Category theory but I bet array chaining has a name in category theory. Is it monoid? I was asking a long time ago about a proof of concept library that I've written and someone said that it's monoid.

I'm talking about code like this:

const result = [1,2,3,4].map(x => x * 2)
                        .filter(x => x % 2 == 0)
                        .filter(x => x > 4)

Each method returns a new object of the same type that is modified.

but you can also use a method that returns different types like single values (Array::find Array::reduce).

What objects in Category theory have the same behavior/rules?

Would it be a Monad if there were only methods that return the new Array?

I wanted to ask on Software Engineering, but it lacks a Category Theory tag.

0

There are 0 best solutions below