#3707: deriving Data, Typeable for empty data decls
------------------------------+---------------------------------------------
Reporter: seanmcl | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 6.10.4
Resolution: invalid | Keywords:
Difficulty: | Os: Unknown/Multiple
Testcase: | Architecture: Unknown/Multiple
Failure: None/Unknown |
------------------------------+---------------------------------------------
Changes (by simonpj):
* status: new => closed
* difficulty: =>
* resolution: => invalid
Old description:
> Empty data decls are useful for things like phantom types. However,
> deriving (Data, Typeable) does not work with them, so if you want to use
> them with generics you must do something like the following:
>
> data PredTag
>
> instance Typeable PredTag where
> typeOf _ = G.mkTyConApp (G.mkTyCon "PredTag") []
>
> Surely GHC could derive this for us!
New description:
Empty data decls are useful for things like phantom types. However,
deriving (Data, Typeable) does not work with them, so if you want to use
them with generics you must do something like the following:
{{{
data PredTag
instance Typeable PredTag where
typeOf _ = G.mkTyConApp (G.mkTyCon "PredTag") []
}}}
Surely GHC could derive this for us!
Comment:
When you say it "does not work" can you supply a test case? I tried this:
{{{
{-# LANGUAGE EmptyDataDecls, DeriveDataTypeable #-}
module T3707 where
import Data.Typeable
data PredType deriving( Typeable )
}}}
That works fine in GHC 6.10 and the HEAD.
You do get a complaint if you derive 'Data' for such a type, but I'm not
sure that makes sense.
I'll close this ticket, but please re-open if I have missed something.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3707#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs