Skip to content

Wingman doesn't respect fundeps #2610

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 Jan 19, 2022 · 1 comment · Fixed by #2611
Closed

Wingman doesn't respect fundeps #2610

isovector opened this issue Jan 19, 2022 · 1 comment · Fixed by #2611
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

isovector commented Jan 19, 2022

Preamble:

class Monoid doc => HasObject doc ndoc | doc -> ndoc, ndoc -> doc where
instance HasObject SwaggerDoc NamedSwaggerDoc where

object ::
  HasObject doc doc' =>
  Text ->
  SchemaP doc A.Object [A.Pair] a b ->
  SchemaP doc' A.Value A.Value a b

class ToSchema a where
  schema :: ValueSchema NamedSwaggerDoc A.Value A.Value a a

if we check in the context of this:

instance ToSchema Rec where
  schema = [wingman| use object
                   , use undefined
                   |]

we get a hole ⊢ SchemaP doc Object [Pair] Rec Rec

but this should actually be SchemaP SwaggerDoc Object [Pair] Rec Rec as per the fundep.

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

Pretty easy fix, all things considered:

apply :: Saturation -> HyInfo CType -> TacticsM ()
apply (Unsaturated n) hi = tracing ("apply' " <> show (hi_name hi)) $ do
  jdg <- goal
  let g  = jGoal jdg
      ty = unCType $ hi_type hi
      func = hi_name hi
  ty' <- freshTyvars ty
  let (_, theta, all_args, ret) = tacticsSplitFunTy ty'
      saturated_args = dropEnd n all_args
      unsaturated_args = takeEnd n all_args
  ctx <- ask
  skolems <- gets ts_skolems
  rule $ \jdg -> do
    unify g (CType $ mkVisFunTys unsaturated_args ret)
    subst <- gets ts_unifier
    let theta' = substTheta subst theta
    let fundeps = foldMap (foldMap fd_eqs . improveFromInstEnv (ctxInstEnvs ctx) (\_ _ -> ())) theta'
        unified = tryUnifyUnivarsButNotSkolemsMany skolems fundeps
    modify $ updateSubst $ maybe emptyTCvSubst id unified

    ext
        <- fmap unzipTrace
        $ traverse ( newSubgoal
                    . blacklistingDestruct
                    . flip withNewGoal jdg
                    . CType
                    . scaledThing
                    ) saturated_args
    pure $
      ext
        & #syn_used_vals %~ (\x -> S.insert func x <> getAncestry jdg func)
        & #syn_val       %~ mkApply func . fmap unLoc

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