Skip to content

Wingman doesn't case split on forall-quantified values #2046

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

Closed
isovector opened this issue Jul 28, 2021 · 3 comments · Fixed by #2049
Closed

Wingman doesn't case split on forall-quantified values #2046

isovector opened this issue Jul 28, 2021 · 3 comments · Fixed by #2049
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

@ssbothwell reports:

import Data.Functor.Contravariant

class Semigroupal cat t1 t2 to f where
  combine :: cat (to (f x y) (f x' y')) (f (t1 x x') (t2 y y'))

comux :: forall p a b c d. Semigroupal Op (,) (,) (,) p => p (a, c) (b, d) -> (p a b, p c d)
comux = _

Wingman can't write this function, even though the implementation is just getOp combine.

@isovector isovector added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: wingman labels Jul 28, 2021
@isovector
Copy link
Collaborator Author

isovector commented Jul 28, 2021

But this is odd, because combine is in the hypothesis:

HyInfo 
  { hi_name = combine
  , hi_provenance = ClassMethodPrv Semigroupal
  , hi_type = forall x y x' y'. Op (p x y, p x' y') (p (x, x') (y, y'))
  }

Thus I'd expect Wingman to try destruct combine, resulting in

case combine of
  Op { getOp = x } -> _

and then solve the hole immediately via assumption.

@isovector
Copy link
Collaborator Author

But the desired goal in comux has type p (a, c) (b, d) -> (p a b, p c d), so maybe there's an issue here where either:

  1. values with forall types can't be destructed
  2. there's a problem unifying the skolemized goal with the forall'd type of x... or is it skolemized here with different skolems? Unclear how the pattern match would/should behave.

@isovector
Copy link
Collaborator Author

Spitting depends on tacticsGetDataCons:

which doesn't peek through forall types neither here:

tacticsGetDataCons ty | Just _ <- algebraicTyCon ty =
splitTyConApp_maybe ty <&> \(tc, apps) ->
( filter (not . dataConCannotMatch apps) $ tyConDataCons tc
, apps
)
tacticsGetDataCons _ = Nothing

nor here:

algebraicTyCon (splitTyConApp_maybe -> Just (tycon, _))

Mystery solved!

@isovector isovector changed the title Wingman refuses to case split on class method Wingman doesn't case split on forall-quantified values Jul 28, 2021
@mergify mergify bot closed this as completed in #2049 Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant