Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#1577 closed feature request (invalid)

Give TH the ability to get the info for a class name

Reported by: iampure@… Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In a module M, where a class G is imported from a module N, I want to get all the methods and arities of G into some Info data structure. I thought Template Haskell already offered this possibility, but sorear claimed with very high confidence that this is not the case. In general: as much information as is available to the compiler should be exposed in the Q monad upto some sane cutoff.

I think Template Haskell is not being used that much, because it has lots of arbitrary limitations and is not documented perfectly in one place. It's a vicious circle: because TH (although it costed lots of implementation effort already) is not perfect, there are little users. Because there are not many users, the implementation isn't perfect.

Change History (8)

comment:1 Changed 11 years ago by simonpj

Well if you reify a class Name you get a ClassI Dec (see Language.Haskell.TH.Syntax). The Dec gives the class signature, and you can then reify the Names you find inside.

So I'm not sure just what you want that isn't provided.

I agree that it's possible that more features in TH would lead to more users, but it's hard to tell just which features! There is a lot that could be done. It'd be a great project for someone to take on.

Meanwhile I'll try to (continue to) respond to concrete suggestions.


comment:2 Changed 11 years ago by iampure@…

In the following code with Foo a class name(i.e. class Foo x y zwhere...) that is is imported from another module:

{{{a = $(do info <- reify (Name (mkOccName "Foo") NameS)

() <- trace (show info) (return ()) (liftM (LitE . StringL) currentModule))}}}

The problem is that whatever I try, I don't get an info value. I basically guessed the NameS constructor, since I don't know what the "S" stands for.

So, the problem is getting access to the Info value. I am either reifying the wrong thing or this feature simply does not work.

comment:3 Changed 11 years ago by simonpj


reify 'Foo

comment:4 Changed 11 years ago by iampure@…

Shouldn't the following work too then with Control.Monad loaded?

 a = reify 'Monad

I get:

Not in scope: data constructor `Monad'

comment:5 Changed 11 years ago by simonpj

Sorry, you want

reify ''Monad

This is described in 4.3 of pointed to from

comment:6 Changed 11 years ago by igloo

Resolution: invalid
Status: newclosed

Looks like this already works to me. Please reopen if I'm wrong.

comment:7 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:8 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.