-
Notifications
You must be signed in to change notification settings - Fork 3
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
Delimiters in outputOf, map, reduce, etc. for #20 #24
Conversation
I agree that it’s suboptimal that these parameters are viral in all the API. I think step 1 would be to add the functionality to Shwift, and not change Script. for Script, I’m thinking the API should just be |
Sounds good! Except I'm not sure how to do The API can't return an So I'll propose a minimal |
done in #26 |
This PR for #20 adds three kinds of delimiters:
segmentingInputAt
)withOutputSeparator
)withOutputTerminator
)The commits should be in an order of likelihood you'd want them in case you want to pick some aspects. I started with the fix for #22 in case you wanted to adopt both at once.
Because the API's call each other, the parameters end up being viral (read: API pollution?), albeit ignorable as defaults. Most changes are in
Script
, where I believe you wanted only a simple API surface. But the ability to reduce text to objects in a parse pipeline is my primary goal, so I hope they're not too noisy. One commit adds docc to at least explain.I chose longer names to try to be Swifty, but I can try to propose shorter ones (
splitAt
?endWith
?).All changes are intended to be source and behavior compatible using the existing defaults. The last commit uses a constant for the default newline to ensure it's consistent and to simplify auditing. Other
"\n"
, e.g., in echo, are not converted because they stem from different semantics.The main demo is just to hint the API to new users.
I'm happy to prune or polish as needed. Thanks!