Ticket #5406 (closed feature request: fixed)
Template Haskell: Reification of type family instances
Description
In Template Haskell, there's no way to find out all instances of a type or data family. Manuel commented on this in an old patch (third dot-point):
Tue Mar 24 20:34:47 PDT 2009 Manuel M T Chakravarty <chak at cse.unsw.edu.au>
* Template Haskell: make reify aware of type families
Ignore-this: 4b9c2d626e7c506a74331bb91d0fcff7
- Reifying a type family returns a TH family declaration
- Reifying a data constructor from a data instance attributes that
constructor to the family (not the representation tycon)
- Ideally, we should have facilities to reify all type/data instances of a
given family (and the same for instances of a class). I haven't added that
here as it involves some API design.
M ./compiler/basicTypes/DataCon.lhs -2 +12
M ./compiler/typecheck/TcSplice.lhs -5 +22
I'm not particularly concerned about the specific API, but the following seems reasonable:
data Info ... | DataFamI Dec [DataFamInstance] | TypeFamI Dec [TypeFamInstance] ... -- | Always a 'DataInstD' or 'NewtypeInstD' constructor type DataFamInstance = Dec -- | Always a 'TySynInstD' constructor type TypeFamInstance = Dec
Alternatively, perhaps the DataFamI and TypeFamI constructors should be discarded in favour of a single FamI constructor.
Change History
Note: See
TracTickets for help on using
tickets.
