[GHC] #14488: Can't define a lens for a field with a constraint
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# LANGUAGE RankNTypes #-} type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s data T a = MkT { _tfield :: Eq a => a } tfield :: Eq a => Lens' (T a) a tfield f t = MkT <$> f (_tfield t) }}} This code compiles with GHC 8.2.1. On GHC 8.0.2 the following error is reported: {{{#!hs tfield.hs:8:22: error: • Couldn't match type ‘a’ with ‘Eq a => a’ ‘a’ is a rigid type variable bound by the type signature for: tfield :: forall a. Eq a => Lens' (T a) a at tfield.hs:7:11 Expected type: f (Eq a => a) Actual type: f a • In the second argument of ‘(<$>)’, namely ‘f (_tfield t)’ In the expression: MkT <$> f (_tfield t) In an equation for ‘tfield’: tfield f t = MkT <$> f (_tfield t) • Relevant bindings include t :: T a (bound at tfield.hs:8:10) f :: a -> f a (bound at tfield.hs:8:8) tfield :: Lens' (T a) a (bound at tfield.hs:8:1) }}} I could not find a relevant GHC ticket. Unless it's a known issue, I am going to create a Phab Diff with this code as a test case to avoid a regression in the future. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): It looks like 3f5673f34a2f761423027bf46f64f7499708725f (`A collection of type-inference refactorings.`) fixed this. A regression test would be much appreciated! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4213 Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * status: new => patch * differential: => Phab:D4213 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4213 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Thanks! Can someone pls commit? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | typecheck/should_compile/T14488 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4213 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * testcase: => typecheck/should_compile/T14488 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | typecheck/should_compile/T14488 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4213 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"0db4627b8baf3255cf16725f8acdd69e27f0ab85/ghc" 0db4627/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="0db4627b8baf3255cf16725f8acdd69e27f0ab85" Test Trac #14488 Summary: The refactoring in 3f5673f34a2f761423027bf46f64f7499708725f also fixed a previously unreported issue in the typechecker that prevented defining a lens to a record field with a constraint. This patch adds a regression test. Test Plan: make test TEST=14488 Reviewers: bgamari Reviewed By: bgamari Subscribers: int-e, rwbarton, thomie GHC Trac Issues: #14488 Differential Revision: https://phabricator.haskell.org/D4213 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14488: Can't define a lens for a field with a constraint -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.0.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | typecheck/should_compile/T14488 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4213 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14488#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC