-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
allow extractors to return any foldable structure #256
Conversation
@@ -685,7 +693,7 @@ | |||
('Maybe') | |||
([]) | |||
(typeEq ('sanctuary-maybe/Maybe@1')) | |||
(function(maybe) { return maybe.isJust ? [maybe.value] : []; }); | |||
(I); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
[], | ||
strMap); | ||
}); | ||
(I); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@@ -1605,10 +1609,10 @@ | |||
(t.url) | |||
(t.supertypes) | |||
(t._test ([])) | |||
(t.extractors.$1); | |||
(t._extractors.$1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We provide the user-provided extractor function here to avoid B (toArray) (B (toArray) (_1))
.
8228f3c
to
f8b873e
Compare
I realized while working on sanctuary-list that we need not require an array of values specifically. Many algebraic data types are foldable, so in some cases the identity function should be able to serve as an extractor function.
I tried generalizing the code to avoid using
toArray
anywhere, but this proved impractical due to uses ofZ.chain
with functions that always return arrays. The solution is to compose each of the extractors withtoArray
, necessitating very few internal changes.