[GHC] #11251: isInstance does not work on Typeable with base-4.8 anymore

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 7.10.1 libraries/base | Keywords: Typeable, | Operating System: Unknown/Multiple isInstance | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs
:set -XTemplateHaskell :m +Data.Tyepable :m +Language.Haskell.TH
--- With GHC 7.8 or earlier versions of GHC (I only tried with GHC 7.6, but my friends tried on 7.8 and earlier versoin)
$(isInstance ''Typeable [ConT ''Char] >>= stringE.show) "True"
--- With GHC 7.10.1
$(isInstance ''Typeable [ConT ''Char] >>= stringE.show) "False" }}}
I have noticed that standalone derivings of Typeable instances in Data.Typeable are disappared magically in base-4.8 of GHC 7.10,also one cannot query the instances of it by using `:i Typeable` in GHCi, however, obviously, I can use `typeOf` function in base-4.8 to get the TypeRep of Char. The problem is that `isInstance` in template-haskell library doesn't know Char and many other types are instances of Typeable anymore. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 javran): * cc: javran (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 goldfire): * owner: => goldfire * component: libraries/base => Template Haskell Comment: Will fix. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 songzh): I also find it is allowed to derive `Typeable` class several times for one data type. I am no with GHC 8.2 {{{ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} import Data.Typeable data TT = TT deriving instance Typeable TT -- allowed to derive twice. deriving instance Typeable TT deriving instance Show TT -- Not allowed to derive twice -- deriving instance Show TT }}} Should this be allowed? Or they are the same problem with this ticket. I speculate these are the same problem since GHC does not know `TT` is already an instance of `Typeable` or not after the first time of deriving. Do I need to open another ticket for this problem? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 songzh): Replying to [comment:2 goldfire]:
Will fix. Thanks!
I want to see what is actually the problems is in `template-haskell` package but I did not find any clue by following the definition of `isInstance`. Could you give me any clues on this problem in the source code of GHC? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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): Re comment:3, we automatically derive a `Typeable` instance for every type, so it should probably be an error to derive it explicitly. Does everyone agree? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 RyanGlScott): FWIW, there is already a warning for this sort of thing in the form of `-Wderiving-typeable`: {{{ $ ghci Bug.hs -Wderiving-typeable GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:6:1: warning: [-Wderiving-typeable] • Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable • In the stand-alone deriving instance for ‘Typeable TT’ | 6 | deriving instance Typeable TT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bug.hs:8:1: warning: [-Wderiving-typeable] • Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable • In the stand-alone deriving instance for ‘Typeable TT’ | 8 | deriving instance Typeable TT | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ }}} Why this isn't enabled in `-Wall` is beyond me. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore -------------------------------------+------------------------------------- Reporter: songzh | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Typeable, | isInstance 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 bgamari):
Why this isn't enabled in `-Wall` is beyond me.
Yes, at this point it sounds like it should be.m -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11251#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11251: isInstance does not work on Typeable with base-4.8 anymore
-------------------------------------+-------------------------------------
Reporter: songzh | Owner: goldfire
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords: Typeable,
| isInstance
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 Ryan Scott
participants (1)
-
GHC