Skip to content

Cannot turn off PathPiece and ToHttpApiData newtype instances for keys #1458

Open

Description

@lf-

Hi!

I'm writing a not-a-webapp and I think it's somewhat odd that Persistent will generate deriving newtype instance FromHttpApiData and likewise for PathPiece for all keys, even though this should not be necessary for non-web users; furthermore there is a mechanism in MkPersistSettings to set mpsDeriveInstances to derive more instances, which could be used to achieve this for web users that want it.

I think that the default mkPersistSettings should probably be changed to include these extra instances, such that it can be overridden if they are not desirable. This would unfortunately be a breaking change for those overriding mpsDeriveInstances while discarding the default value (which was previously empty-list).

deriving newtype instance ToHttpApiData (BackendKey $(pure backendT)) => ToHttpApiData (Key $(pure recordType))
deriving newtype instance FromHttpApiData (BackendKey $(pure backendT)) => FromHttpApiData(Key $(pure recordType))
deriving newtype instance PathPiece (BackendKey $(pure backendT)) => PathPiece (Key $(pure recordType))

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions