[GHC] #10156: Unable to coerce with flipped Coercible context

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.10.1-rc2 Component: Compiler | Operating System: Unknown/Multiple (Type checker) | Type of failure: None/Unknown Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- {{{#!hs coerce' :: Coercible a b => b -> a coerce' = coerce }}} doesn't compile, forcing workarounds like: {{{#!hs coerce' :: forall a b. Coercible a b => b -> a coerce' = coerce (id :: a -> a) }}} This arises in practice in several places in the `profunctors` package and `lens`. https://github.com/ekmett/profunctors/blob/1c3508e5274a0ed03765c569596a8fda8... http://hackage.haskell.org/package/lens-4.8/docs/src/Control-Lens- Internal-Coerce.html#coerce%27 Ideally we'd be able to retire `coerce'` entirely and just use `coerce` in those contexts. The tricky part is of course avoiding infinite loops once you add symmetry. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by glguy): * cc: glguy (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): I happen to be playing in this area this minute. Will try to fix this. But not for 7.10. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: infoneeded Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => infoneeded Comment: I can't reproduce this with RC2. I wouldn't expect it to work in 7.8, but it should work in 7.10. (When I saw the ticket, I was quite surprised it didn't, as I thought the new solver handled symmetry!) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: infoneeded Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by glguy): The feature request is that coerce' should not be necessary {{{ {-# LANGUAGE ScopedTypeVariables #-} module FeatureRequest where import Data.Coerce data Iso a b = Iso (a -> b) (b -> a) -- coerceIso :: Coercible a b => Iso a b -- desired coerceIso :: (Coercible a b, Coercible b a) => Iso a b -- required coerceIso = Iso coerce coerce coerce' :: forall a b. Coercible a b => b -> a coerce' = coerce (id :: a -> a) coerceIso' :: Coercible a b => Iso a b -- work around coerceIso' = Iso coerce coerce' }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: infoneeded Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.1-rc2 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): The following module compiles with 7.10 RC2 on my machine: {{{ module T10156 where import Data.Coerce data Iso a b = Iso (a -> b) (b -> a) coerceIso :: Coercible a b => Iso a b coerceIso = Iso coerce coerce }}} This looks like what you want. Is there something I'm missing here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.4 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ekmett): * status: infoneeded => closed * version: 7.10.1-rc2 => 7.8.4 * resolution: => invalid Comment: My mistake. It works in 7.10, but not 7.8. I was testing on the wrong box. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10156: Unable to coerce with flipped Coercible context
-------------------------------------+-------------------------------------
Reporter: ekmett | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.8.4
checker) | Keywords:
Resolution: invalid | Architecture:
Operating System: Unknown/Multiple | Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#10156: Unable to coerce with flipped Coercible context -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.4 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | typecheck/should_compile/T10156 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => typecheck/should_compile/T10156 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10156#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC