RE: [Haskell-cafe] Template haskell instance checking

Not at the moment, I'm afraid, but it's the kind of question that TH ought to be able to answer. I could offer guidance if someone wanted to implement it. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of | heatsink | Sent: 02 March 2006 00:55 | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] Template haskell instance checking | | Is there a way, in template haskell, to find out what instance declarations | exist? I'm not trying to accomplish anything specific right now, but I can | see two potential uses for this. One is to emit compile-time error messages | from TH code which would be more informative than the typechecker's output. | The other is to produce TH functions that conditionally generate code | depending on the instances satisfied by their arguments. | | I offer the following as a motivational example. Suppose you want to write | an extensible library to handle files for, e.g., image data: | | class FileFormat a where | formatName :: a -> String | read :: Handle -> IO a | write :: Handle -> a -> IO () | | instance FileFormat TheStandardFormat where .... | | class (FileFormat a, FileFormat b) => Convert a b where | convert :: a -> b | | Now it would be nice to generate instances of (Convert a TheStandardFormat, | Convert TheStandardFormat b) => Convert a b _except_ where there is an | explicit definition for (Convert a b). AFAIK, there's no way to do this at | present, but it seems like something that could be computed in TH. | | --heatsink | | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (1)
-
Simon Peyton-Jones