Skip to content

reify yields incorrect TupleT at higher-kinds

Line 1175 of changeset:0237ed67 introduces a bug where reify yields an application of TupleT where its argument is too small when the type being reified is of a higher-kind than *.

For example, in the Applicative instance for ((,) a); the (,) gets reified as TupleT 1 instead of TupleT 2.

Here's some code that duplicates its C instance to be a D instance.

{-# LANGUAGE TemplateHaskell, KindSignatures, FlexibleInstances #-}

module ReifyTupleBug where

import Language.Haskell.TH

class C (f :: * -> *)
class D (f :: * -> *)

instance C ((,) Int)

reify ''C >>= \(ClassI _ [i]) ->
  return [InstanceD (ci_cxt i) (foldl AppT (ConT ''D) (ci_tys i)) []]

It results in a kind mis-match:

ReifyTupleBug.hs:13:1: Kind mis-match The first argument ofD' should have kind * -> *', but Int' has kind *' In the instance declaration for D Int' Failed, modules loaded: none.`

I'm not sure how reify_tc_app should be adjusted; perhaps it needs to know the kind at which it is operating and then increment n_tys based on the number of arrows?

Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information