[GHC] #13117: Derived functor instance for void types handles errors badly
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature | Status: new request | Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 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: -------------------------------------+------------------------------------- If we have {{{#!hs data V a deriving (Functor) }}} and we evaluate {{{#!hs f <$> (error "Boo!" :: Void) }}} we should really get a "Boo" error, rather than a useless "Void fmap" one. The offending code is in `compiler/typecheck/TcGenFunctor.hs`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 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: | -------------------------------------+------------------------------------- Comment (by andreas.abel): What should the implementation of `fmap` be here? {{{#!hs fmap _ x = x `seq` error "Void fmap" }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 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: | -------------------------------------+------------------------------------- Comment (by dfeuer): My preference would be {{{#!hs fmap _ x = case x of }}} (effectively using `EmptyCase`). mpickering indicates there was some prior dispute about this, but I don't know where. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #7401 Comment: The discussion is at #7401, which proposed an overhaul of the way derived instances for void types work. Ultimately, a consensus was never reached as to how derived `Eq` instances should work. See https://ghc.haskell.org/trac/ghc/ticket/7401#comment:46. If someone would be willing revive that discussion and advocate for a position, I'd be very appreciative, as I'm hesitant to poke that sleeping dragon again :) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): David has started a new discussion about this proposed change at the Haskell libraries mailing list here: https://mail.haskell.org/pipermail/libraries/2017-January/027590.html -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by David Feuer <David.Feuer@…>): In [changeset:"69f070d8e4d6043937e3405675ac911448bfcb44/ghc" 69f070d/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="69f070d8e4d6043937e3405675ac911448bfcb44" Deriving for phantom and empty types Make `Functor`, `Foldable`, and `Traversable` take advantage of the case where the type parameter is phantom. In this case, * `fmap _ = coerce` * `foldMap _ _ = mempty` * `traverse _ x = pure (coerce x)` For the sake of consistency and especially simplicity, make other types with no data constructors behave the same: * `fmap _ x = case x of` * `foldMap _ _ = mempty` * `traverse _ x = pure (case x of)` Similarly, for `Generic`, * `to x = case x of` * `from x = case x of` Give all derived methods for types without constructors appropriate arities. For example, ``` compare _ _ = error ... ``` rather than ``` compare = error ... ``` Fixes #13117 and #13328 Reviewers: austin, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: ekmett, RyanGlScott, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3374 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): There are still several types that have not reached what I'd consider a good final status, but as Ryan indicates, we need more discussion to get that done. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401, #10577 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: #7401 => #7401, #10577 Comment: Indeed. However, this ticket specifically concerns `Functor`, right? It might be best to tackle the other classes in #10577. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401, #10577 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => closed * resolution: => fixed Comment: Replying to [comment:7 RyanGlScott]:
Indeed. However, this ticket specifically concerns `Functor`, right? It might be best to tackle the other classes in #10577.
Indeed! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401, #10577 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => deriving -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13117: Derived functor instance for void types handles errors badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7401, #10577 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"1317ba625d40fbd51cb0538b3fde28f412f30c01/ghc" 1317ba62/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="1317ba625d40fbd51cb0538b3fde28f412f30c01" Implement the EmptyDataDeriving proposal This implements the `EmptyDataDeriving` proposal put forth in https://github.com/ghc-proposals/ghc- proposals/blob/dbf51608/proposals/0006-deriving-empty.rst. This has two major changes: * The introduction of an `EmptyDataDeriving` extension, which permits directly deriving `Eq`, `Ord`, `Read`, and `Show` instances for empty data types. * An overhaul in the code that is emitted in derived instances for empty data types. To see an overview of the changes brought forth, refer to the changes to the 8.4.1 release notes. Test Plan: ./validate Reviewers: bgamari, dfeuer, austin, hvr, goldfire Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #7401, #10577, #13117 Differential Revision: https://phabricator.haskell.org/D4047 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13117#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC