Skip to content

reifyInstances doesn't work with closed type families

Summary

reifyInstances throws an error when applied to the name of a closed type family

Bug.hs:(13,1)-(15,9): error:
    • reifyInstances: ‘ClosedFam’
        is not a class constraint or type family application
    • In the argument of reifyInstances: Bug.ClosedFam

Steps to reproduce

  • Compile the following module
  • Observe that an error is thrown by reifyInstances
{-# LANGUAGE TemplateHaskell #-}
module Bug
  where

import           Language.Haskell.TH

-- Select between these two lines
--
-- While the open type family works, the closed one doesn't

type family ClosedFam where
-- type family ClosedFam

do
  reifyInstances ''ClosedFam []
  pure []

Expected behavior

reifyInstances to return the list of matching equations in ClosedFam. Or at the very least for the error message not to confuse me by saying that ClosedFam isn't a type family.

Environment

  • GHC version used: 8.8.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information