Skip to content

Template Haskell: reify is not consistent with the special constructors ListT and TupleT

While reify provides consistent type information for arrows (i.e. returns the special ArrowT constructor and not ConT "GHC.Prim.(->)"), that doesn't happen with ListT and TupleT.

Prelude> :m +Language.Haskell.TH
Prelude Language.Haskell.TH> let seeType n = do {VarI _ t _ _ <- reify n; runIO $ putStrLn $ show t; [|1|]}
Prelude Language.Haskell.TH> let {f = undefined :: Int -> Int; g = undefined :: [Int]; h = undefined :: (Int, Int)}
Prelude Language.Haskell.TH> $(seeType (mkName "f"))
AppT (AppT ArrowT (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT ArrowT (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT ArrowT (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT ArrowT (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
1
Prelude Language.Haskell.TH> $(seeType (mkName "g"))
AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
1
Prelude Language.Haskell.TH> $(seeType (mkName "h"))
AppT (AppT (ConT Data.Tuple.(,)) (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT (ConT Data.Tuple.(,)) (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT (ConT Data.Tuple.(,)) (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
AppT (AppT (ConT Data.Tuple.(,)) (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
1

For g and h the expected returned types are:

AppT ListT (ConT GHC.Base.Int)
AppT (AppT (TupleT 2) (ConT GHC.Base.Int)) (ConT GHC.Base.Int)
Trac metadata
Trac field Value
Version 6.8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information