Repository navigation
Remove Functor instance from Referenced - #126
Open
clintonmead wants to merge 1 commit into
Open
clintonmead wants to merge 1 commit into
clintonmead wants to merge 1 commit into
Conversation
`Referenced` was defined as follows: ``` data Referenced a = Ref Reference | Inline a deriving (Eq, Show, Functor, Data, Typeable) ``` Problem is lets say you've got a `Referenced Schema`, if you have: ``` f :: Schema -> Schema x :: Referenced Schema ``` Then `fmap f x` may actually do nothing. Including not updating the referenced `Schema`. Perhaps this behaviour is wanted at times, but I think enough of the time it's surprising enough to warrent callers being explicit about this. The constructors of `Referenced` are exposed, so one can always instead do: ``` \case ref@(Ref )_ -> ref Inline x -> Inline (f x) ``` if they really want that sort of behaviour. This may cause compile errors in downstream libraries that depend on this instance, but I suspect at least some of such usages may be bugs.
clintonmead
force-pushed
the
remove-referenced-functor-instance
branch
from
November 16, 2026 03:37
ae17ae7 to
def1ff2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Referencedwas defined as follows:Problem is lets say you've got a
Referenced Schema, if you have:Then
fmap f xmay actually do nothing. Including not updating the referencedSchema.Perhaps this behaviour is wanted at times, but I think enough of the time it's surprising enough to warrent callers being explicit about this.
The constructors of
Referencedare exposed, so one can always instead do:if they really want that sort of behaviour.
This may cause compile errors in downstream libraries that depend on this instance, but I suspect at least some of such usages may be bugs.