You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As some have probably already run into, NoUnused.CustomTypeConstructorArgs has some false positives, where it tells you that Int in type A = A Int is unused because it is never extracted but in some places you do value == A 0.
The way I’m currently thinking of resolving this is to register all the types that are used directly or indirectly in comparisons (== or /=), and to not report issues for those types at all. So if you have a type alias Record = { a : A, ... } and I notice that something is a Record and is being used in a comparison, then it won’t report the constructor arguments of A.
This would require (or become a lot easier?) with type information, though I think it’ll still be a difficult rule to write.
In some cases, it might still be complicated to notice that something is used as a comparison. For instance, when something is used as the key of a Dictionary (like AssocList). One option here is to look at dependencies’ code to notice that == is used in the implementation on the key, therefore whatever key is passed to an AssocList.Dict is marked as being compared. If that doesn’t work, then asking for configuration could be used as a stop-gap measure (or a temporary measure until we can visit dependencies)
I’m thinking the same thing will probably be useful for other data that is stored, like tuples and record fields. So I’m thinking maybe instead of having NoUnused.CustomTypeConstructorArgs, NoUnused.RecordFields (#15) and NoUnused.TupleFields (#16), we could have a single NoUnused.Data/NoUnused.Fields rule (name TBD).
The text was updated successfully, but these errors were encountered:
As some have probably already run into,
NoUnused.CustomTypeConstructorArgs
has some false positives, where it tells you thatInt
intype A = A Int
is unused because it is never extracted but in some places you dovalue == A 0
.The way I’m currently thinking of resolving this is to register all the types that are used directly or indirectly in comparisons (
==
or/=
), and to not report issues for those types at all. So if you have atype alias Record = { a : A, ... }
and I notice that something is aRecord
and is being used in a comparison, then it won’t report the constructor arguments ofA
.This would require (or become a lot easier?) with type information, though I think it’ll still be a difficult rule to write.
In some cases, it might still be complicated to notice that something is used as a comparison. For instance, when something is used as the key of a Dictionary (like
AssocList
). One option here is to look at dependencies’ code to notice that==
is used in the implementation on the key, therefore whatever key is passed to anAssocList.Dict
is marked as being compared. If that doesn’t work, then asking for configuration could be used as a stop-gap measure (or a temporary measure until we can visit dependencies)I’m thinking the same thing will probably be useful for other data that is stored, like tuples and record fields. So I’m thinking maybe instead of having
NoUnused.CustomTypeConstructorArgs
,NoUnused.RecordFields
(#15) andNoUnused.TupleFields
(#16), we could have a singleNoUnused.Data
/NoUnused.Fields
rule (name TBD).The text was updated successfully, but these errors were encountered: