Skip to content

Use SqlBackend instances as the foundation of SqlFor instances #20

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aljce
Copy link

@aljce aljce commented Apr 25, 2023

This PR solves: #19

Copy link
Owner

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great modification and really simplifies things, thank you!

Please revert all the formatting changes.

Comment on lines 271 to 272
downcastPersistRecordBackend :: forall record backend. PersistRecordBackend record (SqlFor backend) :- PersistRecordBackend record SqlBackend
downcastPersistRecordBackend = unsafeCoerceConstraint
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:- is the type of entailment IIRC - so we're saying "If there's a PersistRecordBackend record (SqlFor backend) instance, please coerce that into PersistRecordBackend record SqlBackend.

This currently works because SqlFor is a newtype over SqlBackend. Can we make this safer by using the Coercible constraint that exists? Coercible (SqlFor backend) SqlBackend => ... is a redundant constraint, but at least if the newtype is changed then we aren't breaking things.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea great idea

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

Successfully merging this pull request may close these issues.

2 participants