Opened 10 years ago

Closed 5 years ago

#1849 closed bug (fixed)

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

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 6.8.1
Keywords: Cc: alfonso.acosta@…, eir@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: T1849
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

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)

Change History (11)

comment:1 Changed 10 years ago by guest

Cc: alfonso.acosta@… added

comment:2 Changed 10 years ago by guest

Component: CompilerTemplate Haskell

comment:3 Changed 10 years ago by igloo

difficulty: Unknown
Milestone: 6.10 branch

comment:4 Changed 10 years ago by simonpj

I think this is likely to be easily fixed, but don't want to fix it if you and Ian agree in the end to eliminate the ListT and TupleT constructors! So shall it wait pending that decision?

Simon

comment:5 in reply to:  4 Changed 10 years ago by guest

Replying to simonpj:

I think this is likely to be easily fixed, but don't want to fix it if you and Ian agree in the end to eliminate the ListT and TupleT constructors!

As I recently wrote in the template-haskell list [1], I think the special type constructors should be kept as long as all redundancies are eliminated (i.e. template-haskell should only return tuple list and arrow types to the user in the form of ListT ArrT and TupleT; never using ConT).

According to that, current behaviour of reify is redundant, that's why I opened this ticket. Let's see what Ian thinks.

In the same message I also proposed separating constructors from types themselves, ... but that's another story.

[1] http://www.haskell.org/pipermail/template-haskell/2007-November/000649.html

comment:6 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:7 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:8 Changed 8 years ago by igloo

Milestone: 6.10 branch_|_

comment:9 Changed 5 years ago by morabbin

Type of failure: None/Unknown

Bump; what does Ian think?

comment:10 Changed 5 years ago by goldfire

Cc: eir@… added

comment:11 Changed 5 years ago by igloo

Resolution: fixed
Status: newclosed
Test Case: T1849

I don't think there's any current plan to remove ListT and TupleT, but we now get the desired output in HEAD. I've added a test.

Note: See TracTickets for help on using tickets.