[GHC] #7867: Allow template-haskell to communicate with itself between compilation units through the interface file

GHC cvs-ghc at haskell.org
Fri Apr 26 16:40:55 CEST 2013


#7867: Allow template-haskell to communicate with itself between compilation units
through the interface file
-----------------------------+----------------------------------------------
Reporter:  errge             |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Template Haskell
 Version:  7.6.3             |       Keywords:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
 Failure:  None/Unknown      |      Blockedby:                  
Blocking:                    |        Related:                  
-----------------------------+----------------------------------------------
 I'd like to be able to have something like this in the Q monad:

   type MessageName = String -- or something better, I don't know
   writeIface :: (Quasi q, Serializable a) => MessageName -> a -> q ()
   readIfaces :: (Quasi q, Serializable a) => MessageName -> q [a]

 Or instead of returning [a], I'm of course fine with a Monoid, I just need
 the gathered results for every occurrance of the MessageName.

 This has to be in the interface file, because I'd like this to work
 through compilation units, like class instances, I'd like to get every
 result in the readIfaces call that is ever imported from the current
 module (transitive closure).

 Please note, that in a very hacky way this is already possible to do by
 abusing classes.  Namely, I create an empty class for my message type.
 When I want to send a message, I create a new empty datatype named for the
 message and I make this an instance of the class.  Then on the receiving
 side I just have to reify the class and I will receive all my instance
 names/messages.

 This came up while implementing the HFlags library:
 http://hackage.haskell.org/package/hflags

 Maybe I shouldn't be proud of this, but we currently do the hacky way
 explained above.  I would love to have a clean approach.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7867>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list