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

Strictly typed form row #5

Open
tp opened this issue Aug 8, 2015 · 4 comments
Open

Strictly typed form row #5

tp opened this issue Aug 8, 2015 · 4 comments

Comments

@tp
Copy link

tp commented Aug 8, 2015

Hi,

really liking the ease and clarity of most his project :-)

While using protocols is great in principle, in practice a lot of the rows are ConcreteFormRow instances and therefore not super strictly type (for example Action = (AnyObject?) -> Void).

Would you be open to discuss more specific row types?

They would probably just end up being FormRow, but then allow for event stricter code.

@fcanas
Copy link
Owner

fcanas commented Aug 8, 2015

Thanks for your interest!

I'm definitely open to revamping the types. I started this project before I really internalized swift's type system the power and purpose of protocols.

The part of this library I like the most is the general shape of the interface, declaratively creating a form, compliance validations... Everything under the hood has a lot of room for improvement.

I erred on the side of more flexibility when I started and that over-complicated things. I think it's time to restrict the interface, make it clean and useful, and maybe reintroduce flexibility as needed.

@fcanas
Copy link
Owner

fcanas commented Aug 9, 2015

@tp I'm interested in seeing a brief proposal 👓 of how you think this should be accomplished.

Or maybe my break-out of TextEntryFormRow 📝 is the kind of design you mean? In which case, 🎊 🎈 I'd be interested in seeing what additional types you'd like to see broken out, or how to improve those interfaces further.

@tp
Copy link
Author

tp commented Aug 9, 2015

I had a stab yesterday at trying new protocols that would allow for strictly typed rows, but I was not able to define a protocol with generic types, that classes could implement as DecimalRow: FormRow<Double> or EmailRow: FormRow`.

Maybe my thinking was wrong and not aligned with Swift or it is not yet possible in 1.2.

Definitely need to look further into this.

@fcanas
Copy link
Owner

fcanas commented Aug 10, 2015

I think the trouble is going to be that it can't be a generic row with heterogenous associated types, while also keeping a strongly-typed collection of those rows 😞

I've considered using an enum with associated types, but then that really cuts down on extensibility from outside the library.

I think we'll need to tinker with possible structures to see if we can come up with anything.

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

No branches or pull requests

2 participants