Skip to content

Reifying closed type families is broken

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.
Trac metadata
Trac field Value
Version 7.8.1-rc2
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