-
-
Notifications
You must be signed in to change notification settings - Fork 389
Tactics plugin doesn't make use of existential or type equality constraints #1285
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
Comments
The first one I think will be hard to nail; right now we only look at the given context for typeclass methods. But admittedly, the typeclass support right now is terrible. So I'll keep this usecase in mind when I rethink how to do it. The equalities should be easy to tackle. |
I think you'd have to look at all patterns used that are in scope for the expression and add them to the given constraints, probably by walking up the AST from the hole. For existentials you can bring them into scope as new skolems. For actually solving them when they aren't already in scope, probably a lot more complicated beyond just pattern matching every variable in scope known to have a type with constructors with contexts. I would think you might want to actually consider that for some single constructor types like :~: or Dict though. const () (_ :: forall f a b . Functor f => (a -> b) -> (f a -> f b)) Doesn't consider Functor f as a given, but if it were a top level signature on a binding for a hole it would. This might need to walk up the AST too. |
@Jashweii do you have a use case in mind for needing to fill holes like |
@isovector -- i have some limited domain of types i am operating on
data RestrictedType a = a ~ Int => I | Bool ~ a => B
-- and i know these constraints for all of those types (in practice this would be (c Int, c Bool) and (c a => r) with c explicitly instantiated at call sites)
withConstraints :: RestrictedType a -> ((Show a, Read a, Ord a) => r) -> r
withConstraints I r = r -- supply int proof to r
withConstraints B r = r -- supply bool proof to r
-- and wish to use them
readR :: RestrictedType a -> String -> a
readR i a = withConstraints i (_ a) -- in practice the hole may be inside a large subexpression, e.g. a do block GHC correctly suggests read as a valid hole fit, with the constraints listed in the error message for the hole, while tactics doesn't try to make (String -> a) given (Show a, Read a, Ord a) - the same as for a signature. |
|
I just checked, and unfortunately the only type information that GHC gives us at that hole is |
Given the following:
The tactics plugin cannot derive any of the following holes:
(HLS - current master, GHC 8.10.3)
The text was updated successfully, but these errors were encountered: