Skip to content

Remove Functor instance from Referenced - #126

Open
clintonmead wants to merge 1 commit into
biocad:masterfrom
clintonmead:remove-referenced-functor-instance
Open

clintonmead wants to merge 1 commit into
biocad:masterfrom
clintonmead:remove-referenced-functor-instance

Conversation

@clintonmead

Copy link
Copy Markdown

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.

`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
clintonmead force-pushed the remove-referenced-functor-instance branch from ae17ae7 to def1ff2 Compare November 16, 2026 03:37
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.

1 participant