Remove inappropriate SafeToInsert constraints #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Persistent 2.14 introduced the
SafeToInsert
class to flag a record as being usable with theinsert
; is a record is not "safe to insert" then it must be inserted withinsertKey
.#66 introduced a compatibility class
GraphulaSafeToInsert
to allowgraphula
to be usable with persistent >=2.14. However, it did so by placing excessiveGraphulaSafeToInsert
constraints.node
(which handles cases where the record's key source isSourceDefault
orSourceArbitrary
) this is somewhat overconstrained;SafeToInsert
should be necessary when the record's key source isSourceDefault
, but it should not be necessary when the key isSourceArbitrary
, since we will always be generating a key to use for the insert.nodeKeyed
, theSafeToInsert
constraint should not be needed at all, since a key has been provided.This PR fixes those constraints, though it isn't easy to see because some of it is buried under a handful of type-level functions. (I acknowledge that this implementation could probably be made prettier, though it's "good enough for now" IMO.)
MonadGraphulaFrontend
now needs a newinsertKeyed
function in addition toinsert
, because insertions with and without a key now require different calls to Persistent. This is the cause for the major version bump, as it will be a breaking change for any instances of the class.Upgrading to this version of graphula (and adding
SafeToInsert
constraints to a handful of functions) is necessary and sufficient for upgradingmegarepo/backend
to the latestpersistent
.