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

allow extractors to return any foldable structure #256

Merged
merged 1 commit into from
Apr 5, 2019

Conversation

davidchambers
Copy link
Member

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 of Z.chain with functions that always return arrays. The solution is to compose each of the extractors with toArray, necessitating very few internal changes.

@davidchambers davidchambers requested a review from Avaq April 3, 2019 17:05
@@ -685,7 +693,7 @@
('Maybe')
([])
(typeEq ('sanctuary-maybe/Maybe@1'))
(function(maybe) { return maybe.isJust ? [maybe.value] : []; });
(I);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

[],
strMap);
});
(I);
Copy link
Member Author

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);
Copy link
Member Author

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)).

@davidchambers davidchambers force-pushed the davidchambers/generalize branch from 8228f3c to f8b873e Compare April 5, 2019 10:53
@davidchambers davidchambers merged commit 574ef50 into master Apr 5, 2019
@davidchambers davidchambers deleted the davidchambers/generalize branch April 5, 2019 10:57
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

Successfully merging this pull request may close these issues.

2 participants