Opened 4 years ago

Closed 3 years ago

#11463 closed bug (fixed)

Template Haskell applies too many arguments to kind synonym

Reported by: RyanGlScott Owned by:
Priority: normal Milestone: 8.0.1
Component: Template Haskell Version: 8.0.1-rc1
Keywords: TypeInType Cc: goldfire
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D2081
Wiki Page:


Running the following code:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeInType #-}
module IdStarK where

import Data.Kind
import Language.Haskell.TH

type Id a = a
data Proxy (a :: Id k) = Proxy

$(return [])

main :: IO ()
main = do
  putStrLn $(reify ''Proxy >>= stringE . pprint)
  putStrLn $(reify ''Proxy >>= stringE . show)

Gives a result I wouldn't have expected:

$ /opt/ghc/head/bin/runghc IdStarK.hs 
data IdStarK.Proxy (a_0 :: IdStarK.Id * k_1) = IdStarK.Proxy
TyConI (DataD [] IdStarK.Proxy [KindedTV a_1627394516 (AppT (AppT (ConT IdStarK.Id) StarT) (VarT k_1627394515))] Nothing [NormalC IdStarK.Proxy []] [])

From the output, it appears that Id is being applied to two arguments, both * and k! Perhaps this indirectly (or directly) a consequence of #11376?

Change History (6)

comment:1 Changed 4 years ago by goldfire

Keywords: TypeApplications removed

No -- this is not #11376. I'll put this in my queue. My guess is that we just need a filterInvisibles somewhere in TcSplice.

comment:2 Changed 3 years ago by RyanGlScott

Differential Rev(s): Phab:D2081
Status: newpatch

comment:3 Changed 3 years ago by goldfire

Hooray! Thanks!

comment:4 Changed 3 years ago by bgamari

Milestone: 8.0.1
Status: patchmerge

comment:5 Changed 3 years ago by Ben Gamari <ben@…>

In 02a5c58/ghc:

Filter out invisible kind arguments during TH reification

Previously, all kind arguments were being reified, which would cause
something like this:

type Id a = a
data Proxy (a :: Id k) = Proxy

to output

data Proxy (a :: Id * k) = Proxy

when `Proxy`'s `Info` is reified. The fix is simple: simply call
`filterOutInvisibleTypes` on the kind arguments of a kind synonym

Fixes #11463.

Test Plan: ./validate

Reviewers: austin, bgamari, goldfire

Reviewed By: goldfire

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11463

comment:6 Changed 3 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.