Skip to content

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

Open

Description

@wraithm

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?

Activity

  1. fizruk commented on Apr 8, 2019

    @fizruk
    Owner

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

  2. wraithm commented on Apr 8, 2019

    @wraithm
    Author

    @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.

  3. phadej commented on Apr 8, 2019

    @phadej
    Collaborator

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

  4. wraithm commented on Apr 8, 2019

    @wraithm
    Author
  5. phadej commented on Apr 8, 2019

    @phadej
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions