Data and Typeable instances for GenericPackageDescription

Hello, I was wondering if there are instances for Typeable and Data available somewhere for GenericPackageDescription. Automatic deriving fails, probably, if I read the docs right, because some types in there have more than 7 parameters. It would help me to use the cabal file parsing functions and convert the result automatically to JSON for use in Eclipse through Scion. Of course if there isn't I suppose I can write my own instances and maybe share them with who ever is interested. Thanks! -- JP Moresmau http://jpmoresmau.blogspot.com/

Excerpts from JP Moresmau's message of Tue Jun 15 14:43:28 -0400 2010:
Hello, I was wondering if there are instances for Typeable and Data available somewhere for GenericPackageDescription. Automatic deriving fails, probably, if I read the docs right, because some types in there have more than 7 parameters. It would help me to use the cabal file parsing functions and convert the result automatically to JSON for use in Eclipse through Scion. Of course if there isn't I suppose I can write my own instances and maybe share them with who ever is interested.
I'd like to second this request; I've written some code that digs for data in these structures and Typeable and Data instances would help eliminate some of the boilerplate associated with this task. Cheers, Edward

On Tue, Jun 15, 2010 at 8:48 PM, Edward Z. Yang
Excerpts from JP Moresmau's message of Tue Jun 15 14:43:28 -0400 2010:
Hello, I was wondering if there are instances for Typeable and Data available somewhere for GenericPackageDescription. Automatic deriving fails, probably, if I read the docs right, because some types in there have more than 7 parameters. It would help me to use the cabal file parsing functions and convert the result automatically to JSON for use in Eclipse through Scion. Of course if there isn't I suppose I can write my own instances and maybe share them with who ever is interested.
I'd like to second this request; I've written some code that digs for data in these structures and Typeable and Data instances would help eliminate some of the boilerplate associated with this task.
Cheers, Edward
Unfortunately, using derive and Template Haskell to add these instances "from the outside" fails, for only one minute thing: ModuleName does not export its constructor! I have added the export (on the 1.9.2 darcs version) and I can successfully generated Data instances. So it looks like we'll need to change the code in Cabal itself, either to add that export, or to add deriving/instance clauses on the relevant types. The minimal impact would be to add deriving Data,Typeable to ModuleName and use derive for the rest, maybe in another llibrary, if adding all these clauses on all the types has too much impact. -- JP Moresmau http://jpmoresmau.blogspot.com/

On Tue, 2010-06-15 at 20:43 +0200, JP Moresmau wrote:
Hello, I was wondering if there are instances for Typeable and Data available somewhere for GenericPackageDescription. Automatic deriving fails, probably, if I read the docs right, because some types in there have more than 7 parameters. It would help me to use the cabal file parsing functions and convert the result automatically to JSON for use in Eclipse through Scion. Of course if there isn't I suppose I can write my own instances and maybe share them with who ever is interested.
I'm happy to accept patches. One thing to keep in mind is that the Cabal library must be compilable with hugs and nhc98 as well as ghc. I think that means we cannot use deriving Typeable or Data since, as far as I know, neither of those compilers supports that language extension. Note that the ModuleName constructor is not exported on purpose. Do Data instances make sense for abstract types? Duncan

On Thu, Jun 17, 2010 at 1:21 AM, Duncan Coutts wrote: On Tue, 2010-06-15 at 20:43 +0200, JP Moresmau wrote: Hello, I was wondering if there are instances for Typeable and Data
available somewhere for GenericPackageDescription. Automatic deriving
fails, probably, if I read the docs right, because some types in there
have more than 7 parameters. It would help me to use the cabal file
parsing functions and convert the result automatically to JSON for use
in Eclipse through Scion. Of course if there isn't I suppose I can
write my own instances and maybe share them with who ever is
interested. I'm happy to accept patches. One thing to keep in mind is that the Cabal library must be compilable
with hugs and nhc98 as well as ghc. I think that means we cannot use
deriving Typeable or Data since, as far as I know, neither of those
compilers supports that language extension. Note that the ModuleName constructor is not exported on purpose. Do Data
instances make sense for abstract types? Duncan Yes, I've managed to specify a Data instance for ModuleName without touching
the Cabal source code (using fromString instead of a constructor). So I can
either do them by end for all of them and put that in the Cabal code, and
test for every supported compiler, or we can just put the instances (the
explicit ModuleName and the derive generated ones for all the other) in a
separate library that people can use when they need that functionality, that
can require all these dependencies that we don't want Cabal to have (TH +
derive). Second option is easier (-: I can tell from hackage that it's not
unusual to have libraries only providing instances.
As an aside, ModuleName is the only problematic constructor in 1.8 or 1.9,
as far as I can tell.
--
JP Moresmau
http://jpmoresmau.blogspot.com/
participants (3)
-
Duncan Coutts
-
Edward Z. Yang
-
JP Moresmau