My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 209: cannot derive Data instance for ModuleName
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Type-Defect
Priority-Medium
Proj-Derive


Sign in to add a comment
 
Reported by explicitcall, Aug 04, 2009
when compiling

{-# LANGUAGE TemplateHaskell #-}
import Data.Data
import Data.DeriveTH
import Distribution.ModuleName

$(derive makeData ''ModuleName)

I get 

Not in scope: data constructor `ModuleName'

This is reproducible with derive 2.0 as it is with derive 0.1.4

Comment 1 by ndmitchell, Aug 05, 2009
You can't do this because ModuleName is exported abstractly, so the generated 
definition can't be spliced in as it refers to the hidden constructor name.

One option would be to define gfoldl k r x = r x, so you can't use SYB to operate 
inside ModuleName, but you can construct values containing ModuleName and still derive 
Data on them. Would that meet your needs?
Labels: Proj-Derive
Comment 2 by ndmitchell, Aug 06, 2009
With the darcs version of derive you can do:

$(derive makeDataAbstract ''ModuleName)

That should work - if it doesn't let me know.
Status: Fixed
Sign in to add a comment

Hosted by Google Code