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

FromForm and ToForm instances for (,) and Either #91

Open
wraithm opened this issue Apr 4, 2019 · 5 comments
Open

FromForm and ToForm instances for (,) and Either #91

wraithm opened this issue Apr 4, 2019 · 5 comments

Comments

@wraithm
Copy link

wraithm commented Apr 4, 2019

Does it make sense to have:

instance (FromForm a, FromForm b) => FromForm (a, b) where
    fromForm f = (,) <$> fromForm f <*> fromForm f

and ditto for Either?

@fizruk
Copy link
Owner

fizruk commented Apr 8, 2019

@wraithm not sure, do you have a use case in mind?

@wraithm
Copy link
Author

wraithm commented Apr 8, 2019

@fizruk

The specific example is that I have a form for creating groups of users, and then I have a form for creating users. For certain kinds of groups, I need a form with a "root" user for that group, so I just use a tuple of the basic group form and the new user form for those kinds of group forms.

So, I have two forms on two separate pages, and then I have a third form that is basically just both of those two forms on the same form. Of course, I could make a new data type with a new instance, but it was very convenient to use a tuple, and I was surprised to find that this instance didn't already exist. Also, you could have an Either version of this as well, but the tuple case is what I used for my specific problem here.

@phadej
Copy link
Collaborator

phadej commented Apr 8, 2019

Question: can corresponding ToForm be written? If it can, then I don't see downsides.

@wraithm
Copy link
Author

wraithm commented Apr 8, 2019 via email

@phadej
Copy link
Collaborator

phadej commented Apr 8, 2019

I think we can assume (and mention that in instance haddocks) that forms "read/write" disjoint field sets.

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

3 participants