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
Currently, many predicates make an arbitrary choice whether to require a Show instance or not. If a Show instance is required, then the Predicate can give better explanations, but can't be used as often. This isn't really a choice that's about the predicate, but rather about the type the predicate is used with.
By relying on https://hackage.haskell.org/package/if-instance, it would be possible to defer this decision to the call site, obtaining a Show instance that can be used if it's available, but otherwise falling back to something with worse messages but that still works! That's perfect. However, it's imperfect that if-instance depends on GHC 9.0, and requires that clients use a GHC plugin.
I think the right thing to do here is to create a different package that depends on explainable-predicates, reexports the same Predicate type, but defines the predicates to use optional Show instances via the plugin. Then users who can tolerate a GHC plugin and are using GHC 9.0 could depend in the new package instead.
Notes:
In the long-term, it would be very nice if explainable-predicates made it into GHC. However, that would still mean a delay of years before this package could depend on the functionality because of backward compatibility.
It would be nice if the implementation here could depend on the more generic implementation using if-instance. That would work, except for old GHC compatibility. Perhaps an upstream contribution could widen the range of GHC versions supported by if-instance. If that included everything as far back as 8.6, I think that would be good enough. But 9.0 definitely isn't.
The text was updated successfully, but these errors were encountered:
Currently, many predicates make an arbitrary choice whether to require a
Show
instance or not. If aShow
instance is required, then thePredicate
can give better explanations, but can't be used as often. This isn't really a choice that's about the predicate, but rather about the type the predicate is used with.By relying on https://hackage.haskell.org/package/if-instance, it would be possible to defer this decision to the call site, obtaining a
Show
instance that can be used if it's available, but otherwise falling back to something with worse messages but that still works! That's perfect. However, it's imperfect thatif-instance
depends on GHC 9.0, and requires that clients use a GHC plugin.I think the right thing to do here is to create a different package that depends on
explainable-predicates
, reexports the samePredicate
type, but defines the predicates to use optionalShow
instances via the plugin. Then users who can tolerate a GHC plugin and are using GHC 9.0 could depend in the new package instead.Notes:
explainable-predicates
made it into GHC. However, that would still mean a delay of years before this package could depend on the functionality because of backward compatibility.if-instance
. That would work, except for old GHC compatibility. Perhaps an upstream contribution could widen the range of GHC versions supported byif-instance
. If that included everything as far back as 8.6, I think that would be good enough. But 9.0 definitely isn't.The text was updated successfully, but these errors were encountered: