Open ericelliott opened 5 years ago
Yes, I think we should also add mappable/functor (aliased).
This proposal defines "foldable", "reducer", "iterator" and "iterable" (just in case the last two aren't defined yet — they're ES2015 built-in interfaces.
I'm on the fence. The ECMAScript spec does not capitalize these kinds of types, though they do capitalize all the built-in constructors. Should we follow the same convention? I have been lowercasing all types that are NOT built-in constructors, except for Any
and Void
, I think.
actually, I think the idea to alias "Functor" is probably a bad one. I'd rather reserve that for the higher-kinded type constructor, e.g.:
map = (a => b) => Functor(a) => Functor(b)
I don't have an opinion on this new builtin but it should match our builtin types if its addition is warranted.
Any
, Void
, Iterable
, Predicate
, TypedArray
are all capitalized.
OK, I'm on board. Capitalize all the things!
I think the idea to alias
You should propose these aliases separately; keep it simple for now.
interface Foldable = Reducible | Iterable;
I find this confusing; a lot of people think of fold as an alias of reduce.
Anything that can be iterated can also be reduced. You just have to bring your own reduce()
to the party if the method is missing.
But you're right. I should leave that off.
Oops. Can't leave it off, or it won't work for transducers or a pure reduce()
definition.
Related: #120
I use reducers all the time, and frequently use type parameters in documentation named "reducer", and "foldable". It would probably be a good idea to formally define them.
Example
Mappable
Change IterableObject to Iterable
I know it's a breaking change, but AFAIK, there's not a lot of software relying on this, yet.