-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is isn't transitive #334
Comments
I experimented with this a bit on branch class IsFacts k l => Is k l
type IsFacts k l = (IsFacts1 k l, IsFacts2 k l)
type family IsFacts1 (k :: OpticKind) (l :: OpticKind) :: Constraint where
IsFacts1 k A_Traversal = (Is k A_Fold, Is k A_Setter)
...
IsFacts1 k l = ()
type family IsFacts2 (k :: OpticKind) (l :: OpticKind) :: Constraint where
IsFacts2 An_AffineTraversal k = (Is A_Prism k, Is A_Lens k)
IsFacts2 A_Traversal k = Is An_AffineTraversal k
...
IsFacts2 k l = () and adding This "works", in that e.g. whenever we have It's unfortunate that when an instance context contains a The reflexive case is also somewhat problematic, because either it needs It may be interesting to add more things to So far I don't think the benefit (slightly more convenient handling of definitions that have |
If we have
Is k l
andIs l m
, we do not automatically haveIs k m
even though it holds for all concrete instances. For example:is perfectly fine, but
results in the following mess:
I noticed this looking at the implementation of
adjoin
in #332, where explicitcastOptic
calls are needed to calltoListOf
on a(n optic that can be cast to a) traversal. I wonder if we can provide a bit more information to help out type inference here. General transitivity is probably infeasible (too much guessing) but if we know e.g.Is k A_Traversal
it might be possible to haveIs k A_Fold
etc. available from superclasses?Another question is whether this is worthwhile, given that this most likely only arises within
optics
itself or for users who define their own optics combinators, rather than in normal user code (which will typically have more concrete optics).The text was updated successfully, but these errors were encountered: