I'm not sure I understand how this solves my problem. Its possible that I can use Derive not to need all the newtype declarations at all, but, if I do need them, I'm not sure how Derive reduces the overall amount of boilerplate here.

Perhaps I should define a TH function that takes

     $(newtype' Name String)

And converts it to a

    newtype Name = Name String deriving (Eq,Ord,Read,Show,Typeable)



-Alex-

Neil Mitchell wrote:
Hi

   {-# OPTIONS -fglasgow-exts #-}
   module Blog.Types where
   import Data.Typeable
   import Data.Generics

   data BlogEntry = Entry EpochSeconds Name Email Title Body
                    deriving (Eq,Ord,Read,Show,Typeable)

   newtype Name = Name String deriving (Eq,Ord,Read,Show,Typeable)
   newtype Title = Title String deriving (Eq,Ord,Read,Show,Typeable)
   newtype Body = Body String deriving (Eq,Ord,Read,Show,Typeable)

First off, never use OPTIONS, use OPTIONS_GHC instead. OPTIONS is the
old way of doing it.

Secondly, if you add {-# OPTIONS_DERIVE
--derive=Eq,Ord,Read,Show,Typeable #-} then running your code through
with Derive should give you the magic that you require. Plus it will
also work on Hugs, and not require your OPTIONS_GHC anyway.

Derive: http://www-users.cs.york.ac.uk/~ndm/derive/

Thanks

Neil

_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to