[GHC] #8884: Reifying closed type families is broken

#8884: Reifying closed type families is broken ------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- If I say {{{ {-# LANGUAGE TemplateHaskell, TypeFamilies, PolyKinds #-} module Scratch where import Language.Haskell.TH type family Foo a where Foo x = x $( do FamilyI foo [] <- reify ''Foo runIO $ putStrLn $ show foo return [] ) }}} and compile, I see (with uniques suppressed) {{{ ClosedTypeFamilyD Scratch.Foo [KindedTV a (VarT k)] (Just (AppT (AppT ArrowT (VarT k)) (VarT k))) [TySynEqn [VarT k,VarT x] (VarT x)] }}} There are two problems here: 1. The return kind (the third parameter to `ClosedTypeFamilyD`) should be just that -- the return kind. In the output, we see the full kind of the type family. `k -> k`. 2. The equation includes the kind variable `k`, which should be implicit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken
-------------------------------------+------------------------------------
Reporter: goldfire | Owner: goldfire
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Template Haskell | Version: 7.8.1-rc2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Richard Eisenberg

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by goldfire): * status: new => merge Comment: The fix affects ''open'' type families as well as closed. Both families had exactly the same mis-behavior, upon inspection of the code. Given that, it's unclear to me whether this should be merged. The old behavior was clearly wrong -- for example, reifying a type family and then trying to splice it would end in failure. But, the old behavior was also quite reliable, and it's conceivable that users have noticed the poor behavior and have coded against it. (In fact, a co-author of one of my libraries has done just that, which is how I discovered the GHC bug!) So, we must choose between * Retaining the incorrect behavior (which has been around for some time), while not surprising users in the final 7.8 release, or * Having correct behavior. I slightly favor the latter, believing that this error was so egregious that no one (other than me, evidently) is using this feature of GHC. If anyone else were using the feature, we would have seen the bug report! So, I'm setting this ticket to `merge` but am happy to have others disagree about that decision. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by goldfire): * testcase: => th/T8884 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by carter): how would they even use the incorrect behavior constructively? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): I think we should merge. IBM and Microsoft may sometimes have to maintain old, incorrect behaviour for legacy reasons, but GHC doesn't! Thank you for fixing this. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by goldfire): Replying to [comment:4 carter]:
how would they even use the incorrect behavior constructively?
Note that the incorrect behavior applied to ''open'' type families as well as closed, so this isn't a new bug in 7.8. How could they use it constructively? Reifying a type family gives the list of arguments and the result kind. By counting the number of arguments, a program could remove the same number of arrows from the returned kind to get the actual result kind. It's not too hard, actually. As for the extra kind parameters, I suppose a program could do dependency analysis to discover which variables are kind variables and remove them. In any case, my library (a branch of `singletons`) was able to use the incorrect behavior without too much trouble (once we figured out what was going on), so there's an evidence proof for you. :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): Test case fails on ghc-7.8: {{{ Actual stderr output differs from expected: --- ./th/T8884.stderr 2014-03-17 16:06:49.515482947 +0000 +++ ./th/T8884.comp.stderr 2014-03-17 16:44:36.121051051 +0000 @@ -1,3 +0,0 @@ -type family T8884.Foo (a_0 :: k_1) :: k_1 where T8884.Foo x_2 = x_2 -type family T8884.Baz (a_0 :: k_1) :: * -type instance T8884.Baz x_0 = x_0 *** unexpected failure for T8884(normal) }}} https://s3.amazonaws.com/archive.travis-ci.org/jobs/20947547/log.txt Maybe some test files missing? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by thoughtpolice): Blagh, totally my fault. On it... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): thoughtpolice: Did you get to fix it? It seems the only failing test case missing after Gergo fixed up the failures he caused. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken
-------------------------------------+------------------------------------
Reporter: goldfire | Owner: goldfire
Type: bug | Status: closed
Priority: normal | Milestone: 7.8.1
Component: Template Haskell | Version: 7.8.1-rc2
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: th/T8884 | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by nomeata): * status: closed => merge Comment: The test case fix should also be merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8884: Reifying closed type families is broken -------------------------------------+------------------------------------ Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Template Haskell | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: th/T8884 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by thoughtpolice): * status: merge => closed Comment: Fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8884#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC