[GHC] #15248: Coercions from plugins cannot be stopped from floating out

#15248: Coercions from plugins cannot be stopped from floating out -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Suppose we have {{{#!hs type family (a :: Nat) (b :: Nat) :: Bool }}} that computes whether `a` is less than `b`, where a type checker plugin does the proof work. For some `a`, `b`, and `c`, if we assume `(a b) ~ True` and `(b c) ~ True`, the plugin can prove `(a c) ~ True`. However, GHC currently provides no way for the plugin to indicate that the proof of `(a c) ~ True` depends on the assumptions. This means that the plugin-produced proof evidence could potentially float out of its desired context, inviting disaster. In term of `Coercion`s, I propose that the `PluginProv` constructor of `UnivCoProvenance` be allowed to include a `TyCoVarSet` of "free variables" (that is, assumptions) in the proof. Computing the free variables of the enclosing `UnivCo` would returns these variables, too. It is, of course, up to the plugin to provide the right information here, but plugins generally have enough information to do this correctly (or, at least, to conservatively list all free variables of assumptions as free variables of the conclusion). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15248 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15248: Coercions from plugins cannot be stopped from floating out -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * cc: adamgundry (added) Comment: In this case, in principle, shouldn't the evidence produced for the plugin directly depend on the evidence for the assumptions? That is, rather than "proving" `(a c) ~ True` by `UnivCo`, you would "prove" {{{ (((a b) ~ True, (b c) ~ True) => a c) ~ (((a b) ~ True, (b c) ~ True) => True) }}} by `UnivCo` and then instantiate it with your evidence for `(a b) ~ True` and `(b c) ~ True`. That said, your suggestion might make things easier in practice... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15248#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15248: Coercions from plugins cannot be stopped from floating out -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | TypeCheckerPlugins Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * keywords: => TypeCheckerPlugins -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15248#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15248: Coercions from plugins cannot be stopped from floating out -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | TypeCheckerPlugins Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): But comment:1 seems to require a constrained type in the `~` relation, which is generally not allowed. I suppose nothing stops a plugin from producing such things (and GHC might even consume them correctly), but I don't think that's explicitly a supported feature. (You can't say that in source Haskell, for example. Even with quantified constraints.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15248#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15248: Coercions from plugins cannot be stopped from floating out -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: | TypeCheckerPlugins Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Yes: see comment:15 on #8095, and the discussion on Phab:D4766. `PlugInProv` should have a `TyCoVarSet` just as the (upcoming) `ZappedProv` does, and for the same reasons. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15248#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC