-
Notifications
You must be signed in to change notification settings - Fork 376
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
Add Traversable1 #305
Comments
I don't mean to dismiss your request, but Haskell's |
@nadameu The fact that |
Btw, there's a better way to use |
It is often useful to be able to traverse a non-empty structure with respect to a functor that is not quite
Applicative
, but is neverthelessApply
. A common use case I run into is transposing a <something> of objects into an object of <something>s.The problem is that objects in JS have a straightforward implementation of
lift2
, but lawfully implementingpure
would require the ability to construct infinite objects with the same value at every possible key (this is possible with proxies, but let's not go there).Instead, we want a weakening of the constraints of
Traversable
so that it can work withApply
s. Conversely, the requirements on the traversable container are tightened; more things areTraversable
than areTraversable1
.Here is an example of what an instance might look like for non-empty arrays:
Similar instances exist for non-empty objects themselves, non-empty trees, non-empty sets, etc.
Perhaps obvious, but it's worth noting that all
Traversable1
s areTraversable
for free; since allApplicative
s are (at least)Apply
.The text was updated successfully, but these errors were encountered: