[GHC] #10891: `reify` doesn't find associated type families

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 7.10.2 Haskell | Keywords: template | Operating System: Unknown/Multiple haskell; type families | Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Template Haskell's `reify` doesn't find the the associated type families of a type class. Consider the following two classes: {{{#!hs class C a where f :: a -> Int class C' a where type F a :: * f' :: a -> Int }}} These produce identical, up to renaming, output when passed to `reify`: {{{#!hs -- putStrLn $(stringE . show =<< reify ''C) ClassI (ClassD [] Ghci1.C [PlainTV a_1627398388] [] [SigD Ghci1.f (ForallT [PlainTV a_1627398388] [ClassP Ghci1.C [VarT a_1627398388]] (AppT (AppT ArrowT (VarT a_1627398388)) (ConT GHC.Types.Int)))]) [] -- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [] }}} If I know the name of `F`, I can look up information about it: {{{!#hs -- putStrLn $(stringE . show =<< reify ''F) FamilyI (FamilyD TypeFam Ghci3.F [PlainTV a_1627405973] (Just StarT)) [] }}} But I can't find the name of `F` in the first place. Even if I add an instance of the type class, the `InstanceD` has none of the information about the definition. Given {{{#!hs instance C' [a] where type F [a] = a f' = length }}} we get {{{#!hs -- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [InstanceD [] (AppT (ConT Ghci3.C') (AppT ListT (VarT a_1627406161))) []] }}} This problem was confirmed to exist in the following configurations: * GHC 7.10.2 with version 2.10.0.0 of the template-haskell package. * GHC 7.8.3 with version 2.9.0.0 of the template-haskell package. * GHC 7.4.2 with version 2.7.0.0 of the template-haskell package. (I also posted this on Stack Overflow in //2013//, where it has been languishing ever since: http://stackoverflow.com/q/17247880/237428.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * keywords: template haskell; type families => type families; newcomer * milestone: => 8.0.1 Comment: Well, that's silly. My guess, without looking at the code, that this could be fixed in 2-3 lines. Newcomers? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by osa1: Old description:
Template Haskell's `reify` doesn't find the the associated type families of a type class. Consider the following two classes:
{{{#!hs class C a where f :: a -> Int
class C' a where type F a :: * f' :: a -> Int }}}
These produce identical, up to renaming, output when passed to `reify`:
{{{#!hs -- putStrLn $(stringE . show =<< reify ''C) ClassI (ClassD [] Ghci1.C [PlainTV a_1627398388] [] [SigD Ghci1.f (ForallT [PlainTV a_1627398388] [ClassP Ghci1.C [VarT a_1627398388]] (AppT (AppT ArrowT (VarT a_1627398388)) (ConT GHC.Types.Int)))]) []
-- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [] }}}
If I know the name of `F`, I can look up information about it:
{{{!#hs -- putStrLn $(stringE . show =<< reify ''F) FamilyI (FamilyD TypeFam Ghci3.F [PlainTV a_1627405973] (Just StarT)) [] }}}
But I can't find the name of `F` in the first place. Even if I add an instance of the type class, the `InstanceD` has none of the information about the definition. Given
{{{#!hs instance C' [a] where type F [a] = a f' = length }}}
we get
{{{#!hs -- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [InstanceD [] (AppT (ConT Ghci3.C') (AppT ListT (VarT a_1627406161))) []] }}}
This problem was confirmed to exist in the following configurations:
* GHC 7.10.2 with version 2.10.0.0 of the template-haskell package. * GHC 7.8.3 with version 2.9.0.0 of the template-haskell package. * GHC 7.4.2 with version 2.7.0.0 of the template-haskell package.
(I also posted this on Stack Overflow in //2013//, where it has been languishing ever since: http://stackoverflow.com/q/17247880/237428.)
New description: Template Haskell's `reify` doesn't find the the associated type families of a type class. Consider the following two classes: {{{#!hs class C a where f :: a -> Int class C' a where type F a :: * f' :: a -> Int }}} These produce identical, up to renaming, output when passed to `reify`: {{{#!hs -- putStrLn $(stringE . show =<< reify ''C) ClassI (ClassD [] Ghci1.C [PlainTV a_1627398388] [] [SigD Ghci1.f (ForallT [PlainTV a_1627398388] [ClassP Ghci1.C [VarT a_1627398388]] (AppT (AppT ArrowT (VarT a_1627398388)) (ConT GHC.Types.Int)))]) [] -- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [] }}} If I know the name of `F`, I can look up information about it: {{{#!hs -- putStrLn $(stringE . show =<< reify ''F) FamilyI (FamilyD TypeFam Ghci3.F [PlainTV a_1627405973] (Just StarT)) [] }}} But I can't find the name of `F` in the first place. Even if I add an instance of the type class, the `InstanceD` has none of the information about the definition. Given {{{#!hs instance C' [a] where type F [a] = a f' = length }}} we get {{{#!hs -- putStrLn $(stringE . show =<< reify ''C') ClassI (ClassD [] Ghci3.C' [PlainTV a_1627405973] [] [SigD Ghci3.f' (ForallT [PlainTV a_1627405973] [ClassP Ghci3.C' [VarT a_1627405973]] (AppT (AppT ArrowT (VarT a_1627405973)) (ConT GHC.Types.Int)))]) [InstanceD [] (AppT (ConT Ghci3.C') (AppT ListT (VarT a_1627406161))) []] }}} This problem was confirmed to exist in the following configurations: * GHC 7.10.2 with version 2.10.0.0 of the template-haskell package. * GHC 7.8.3 with version 2.9.0.0 of the template-haskell package. * GHC 7.4.2 with version 2.7.0.0 of the template-haskell package. (I also posted this on Stack Overflow in //2013//, where it has been languishing ever since: http://stackoverflow.com/q/17247880/237428.) -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by osa1): How should default type instances be reified? e.g. if I have something like: {{{#!haskell class C a where type T a :: * type T a = a }}} Syntactically it looks like `TySynD` but semantically it's different. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): That's true that it's different semantically. But Template Haskell is all about syntax, not semantics. But I'd make it a `TySynInstD` instead of a `TySynD` (even though the latter is more syntactically accurate). It seems a bit overwrought to make a new constructor for `Dec` for this case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jstolarek (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by osa1): Another question: Normally we don't fill `InstanceD` contents, probably because we can't anyway -- because we need source code for this, right? But we can still fill information about associated type instances. Should we do this or are there any problems with that? (maybe it's not possible etc.) (By `InstanceD` I mean the one generated for `ClassI`) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: osa1 Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: 1254 -------------------------------------+------------------------------------- Changes (by osa1): * owner: => osa1 * differential: => 1254 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: osa1 Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:1254 -------------------------------------+------------------------------------- Changes (by goldfire): * differential: 1254 => Phab:1254 Comment: That's a good point. If it's easy to do, I think adding the associated type stuff would be nice. But don't go too far out of way to do it. Thanks for jumping in! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: osa1 Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:1254 -------------------------------------+------------------------------------- Changes (by osa1): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: osa1 Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1254 -------------------------------------+------------------------------------- Changes (by osa1): * differential: Phab:1254 => Phab:D1254 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families
-------------------------------------+-------------------------------------
Reporter: antalsz | Owner: osa1
Type: bug | Status: merge
Priority: normal | Milestone: 8.0.1
Component: Template Haskell | Version: 7.10.2
Resolution: | Keywords: type
| families; newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions: Phab:D1254
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1254 -------------------------------------+------------------------------------- Changes (by thomie): * owner: osa1 => * status: merge => new Comment: This commit was reverted in 39a262e53bab3b7cf827fa9f22226da5fca055be. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families
-------------------------------------+-------------------------------------
Reporter: antalsz | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Template Haskell | Version: 7.10.2
Resolution: | Keywords: type
| families; newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1254
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1254 -------------------------------------+------------------------------------- Comment (by thomie): Should this be merged to 7.10? Or can this ticket be closed? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1254 -------------------------------------+------------------------------------- Comment (by goldfire): I argue against merging, as it changes an external interface. My TH code dislikes new, unexpected things being reported. :) If you (whoever reads this next) agree, close the ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10891: `reify` doesn't find associated type families -------------------------------------+------------------------------------- Reporter: antalsz | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: fixed | Keywords: type | families; newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1254 -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10891#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC