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

What about default implementations for SequenceType? #1

Closed
wants to merge 5 commits into from
Closed

What about default implementations for SequenceType? #1

wants to merge 5 commits into from

Conversation

sharplet
Copy link
Contributor

@sharplet sharplet commented Jan 9, 2015

Notes regarding <*>: It doesn't seem possible to create a generic type constraint over a sequence of A -> B, so this version uses [A -> B] as a workaround (which is no problem when combined with <^>, which returns an Array). i.e., Swift borks at this:

func <*> <F: SequenceType, S: SequenceType, A, B where F.Generator.Element == A -> B, S.Generator.Element == A> (fs: F, source: S) -> [B] {
                                                                              ^^^^^^ NOPE

I didn't think too hard about style, naming, etc., that's all up for grabs! Just keen to know if you're into this idea.

It doesn't seem possible to create a generic type constraint over a
sequence of A -> B, so this version uses [A -> B] as a workaround (which
is no problem when combined with <^>, which returns an Array).
@sharplet
Copy link
Contributor Author

sharplet commented Jan 9, 2015

Hmm on second thought, it seems kind of weird to me that these implementations coerce everything into an Array. I'm thinking it might make more sense for this to just be specific to Array.

@gfontenot
Copy link
Collaborator

Yeah, I was going to say the same thing. I think this is awesome, and would love to pull it in, but lets change everything to just be for Array. If people create their own SequenceType... types, then they could also add their own implementations for these functions.

@gfontenot
Copy link
Collaborator

Also, style-wise, lets keep with the T -> U naming scheme for the generics so that it matches with the built in type signature.

@sharplet
Copy link
Contributor Author

Ok, pushed some changes! Let me know what you think.

@gfontenot
Copy link
Collaborator

Fantastic, thank you for this. Squashed and merged in 0755117

@gfontenot gfontenot closed this Jan 12, 2015
@sharplet
Copy link
Contributor Author

🎉✊

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.

None yet

2 participants