-
Notifications
You must be signed in to change notification settings - Fork 321
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
Make Proxy fields optional #792
Comments
AFAIK, Proxy is the only way to do a strict null check without writing custom instances so this may be a breaking change for some users. If we introduce e.g. a |
I would like to provide my motivation for wanting this change. It is sometimes necessary to have a subset of the fields of a structure returned from the API. While it is possible to define two separate structures, it would be easier to have one parametrized structure. data Person f = Person
{ name :: Text
, age :: Natural
, occupation :: f Text
, address :: f Text
, friends :: f [Person]
, pets :: f [Pet]
}
type FullPerson = Person Identity
type PersonSummary = Person Proxy It is currently impossible to define a custom I would also be happy if we could introduce a custom functor for this purpose which would have special treatment. Changing the semantics of data Absent a = Absent |
#564 would solve that, by having a specific instances for field needs, we can make |
- Add combinators for using omit* stuff in manually written instances - Add Manual tests - Cleanup OptionalFields.Common - Fix TH and Generics - Add combinators ToJSON1/2 and FromJSON1/2 - Const, Identity, Tagged and other newtypes - Fix #687. ToJSON1 respects omitting fields - Fix #571. Introduce allowOmittedFields to Generics/TH options. - Resolve #792. () and Proxy can be omitted
The #1038 will make omitting () and Proxy possible.
Using If there are some who want to allow omitted |
- Add combinators for using omit* stuff in manually written instances - Add Manual tests - Cleanup OptionalFields.Common - Fix TH and Generics - Add combinators ToJSON1/2 and FromJSON1/2 - Const, Identity, Tagged and other newtypes - Fix #687. ToJSON1 respects omitting fields - Fix #571. Introduce allowOmittedFields to Generics/TH options. - Resolve #792. () and Proxy can be omitted
- Add combinators for using omit* stuff in manually written instances - Add Manual tests - Cleanup OptionalFields.Common - Fix TH and Generics - Add combinators ToJSON1/2 and FromJSON1/2 - Const, Identity, Tagged and other newtypes - Fix #687. ToJSON1 respects omitting fields - Fix #571. Introduce allowOmittedFields to Generics/TH options. - Resolve #792. () and Proxy can be omitted
- Add combinators for using omit* stuff in manually written instances - Add Manual tests - Cleanup OptionalFields.Common - Fix TH and Generics - Add combinators ToJSON1/2 and FromJSON1/2 - Const, Identity, Tagged and other newtypes - Fix haskell#687. ToJSON1 respects omitting fields - Fix haskell#571. Introduce allowOmittedFields to Generics/TH options. - Resolve haskell#792. () and Proxy can be omitted
There is special treatment of
Maybe
when deriving instances usingGeneric
--Maybe
fields become optional.I think it might make sense to apply the same special treatment to the
Proxy
type --Proxy
fields should probably also be optional -- they can only have one value after all. (And requiring anull
field seems a bit unnecessary)The text was updated successfully, but these errors were encountered: