You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FromForm and ToForm instances for (,) and Either #91
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.
Yes, you can definitely write a ToForm instance for both (,) and Either.
The semantics of toForm after fromForm and vice versa would maybe be a
little weird, but I don't think that matters very much.
Activity
fizruk commentedon Apr 8, 2019
@wraithm not sure, do you have a use case in mind?
wraithm commentedon 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 commentedon Apr 8, 2019
Question: can corresponding
ToFormbe written? If it can, then I don't see downsides.wraithm commentedon Apr 8, 2019
phadej commentedon Apr 8, 2019
I think we can assume (and mention that in instance haddocks) that forms "read/write" disjoint field sets.