Use pragma DeriveGeneric. We are deriving Generic
for the ADT because we want to make the ADT an instance
of NFData.

Signed-off-by: Bhimanavajjula Aditya <[email protected]>
---
 src/Ganeti/Confd/Types.hs         |  2 +-
 src/Ganeti/Errors.hs              |  2 +-
 src/Ganeti/HTools/Types.hs        |  2 +-
 src/Ganeti/Logging.hs             |  3 ++-
 src/Ganeti/Luxi.hs                |  2 +-
 src/Ganeti/Objects.hs             |  2 +-
 src/Ganeti/Objects/Maintenance.hs |  2 +-
 src/Ganeti/OpParams.hs            |  2 +-
 src/Ganeti/Query/Language.hs      |  2 +-
 src/Ganeti/Rpc.hs                 |  2 +-
 src/Ganeti/Ssconf.hs              |  2 +-
 src/Ganeti/THH.hs                 | 27 ++++++++++++++++++---------
 src/Ganeti/Types.hs               |  2 +-
 13 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/src/Ganeti/Confd/Types.hs b/src/Ganeti/Confd/Types.hs
index cfce9ce..90986be 100644
--- a/src/Ganeti/Confd/Types.hs
+++ b/src/Ganeti/Confd/Types.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti confd types.
 
diff --git a/src/Ganeti/Errors.hs b/src/Ganeti/Errors.hs
index 5d64892..0ec175c 100644
--- a/src/Ganeti/Errors.hs
+++ b/src/Ganeti/Errors.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti error types.
 
diff --git a/src/Ganeti/HTools/Types.hs b/src/Ganeti/HTools/Types.hs
index a1fb765..4e3ca8a 100644
--- a/src/Ganeti/HTools/Types.hs
+++ b/src/Ganeti/HTools/Types.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Some common types.
 
diff --git a/src/Ganeti/Logging.hs b/src/Ganeti/Logging.hs
index cf5a3fd..bb23d8c 100644
--- a/src/Ganeti/Logging.hs
+++ b/src/Ganeti/Logging.hs
@@ -1,5 +1,6 @@
 {-# LANGUAGE TemplateHaskell, StandaloneDeriving,
-             GeneralizedNewtypeDeriving #-}
+             GeneralizedNewtypeDeriving,
+             DeriveGeneric #-}
 
 {-| Implementation of the Ganeti logging functionality.
 
diff --git a/src/Ganeti/Luxi.hs b/src/Ganeti/Luxi.hs
index 4439cef..5e3ecc0 100644
--- a/src/Ganeti/Luxi.hs
+++ b/src/Ganeti/Luxi.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti LUXI interface.
 
diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs
index 85f3576..2501e99 100644
--- a/src/Ganeti/Objects.hs
+++ b/src/Ganeti/Objects.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell, FunctionalDependencies #-}
+{-# LANGUAGE TemplateHaskell, FunctionalDependencies, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti config objects.
 
diff --git a/src/Ganeti/Objects/Maintenance.hs 
b/src/Ganeti/Objects/Maintenance.hs
index 2f0c2f8..5f6bd11 100644
--- a/src/Ganeti/Objects/Maintenance.hs
+++ b/src/Ganeti/Objects/Maintenance.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti configuration for the maintenance daemon.
 
diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs
index fbb75e7..cd63771 100644
--- a/src/Ganeti/OpParams.hs
+++ b/src/Ganeti/OpParams.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell, StandaloneDeriving #-}
+{-# LANGUAGE TemplateHaskell, StandaloneDeriving, DeriveGeneric #-}
 
 {-| Implementation of opcodes parameters.
 
diff --git a/src/Ganeti/Query/Language.hs b/src/Ganeti/Query/Language.hs
index 882a9da..1cfec88 100644
--- a/src/Ganeti/Query/Language.hs
+++ b/src/Ganeti/Query/Language.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE TemplateHaskell, CPP, DeriveFunctor, DeriveFoldable,
-             DeriveTraversable #-}
+             DeriveTraversable, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti Query2 language.
 
diff --git a/src/Ganeti/Rpc.hs b/src/Ganeti/Rpc.hs
index a43cc52..3f3f4bb 100644
--- a/src/Ganeti/Rpc.hs
+++ b/src/Ganeti/Rpc.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
-  BangPatterns, TemplateHaskell #-}
+  BangPatterns, TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the RPC client.
 
diff --git a/src/Ganeti/Ssconf.hs b/src/Ganeti/Ssconf.hs
index 99ad3e5..d867cda 100644
--- a/src/Ganeti/Ssconf.hs
+++ b/src/Ganeti/Ssconf.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
 
 {-| Implementation of the Ganeti Ssconf interface.
 
diff --git a/src/Ganeti/THH.hs b/src/Ganeti/THH.hs
index ce51826..f38f781 100644
--- a/src/Ganeti/THH.hs
+++ b/src/Ganeti/THH.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ParallelListComp, TemplateHaskell #-}
+{-# LANGUAGE ParallelListComp, TemplateHaskell, CPP #-}
 
 {-| TemplateHaskell helper for Ganeti Haskell code.
 
@@ -94,6 +94,10 @@ import Data.Maybe
 import qualified Data.Map as M
 import Data.Monoid
 import qualified Data.Set as S
+#if MIN_VERSION_base(4,6,0)
+import GHC.Generics (Generic)
+#else
+#endif
 import Language.Haskell.TH
 import Language.Haskell.TH.Syntax (lift)
 
@@ -335,9 +339,9 @@ loadFnOpt :: Field   -- ^ The field definition
 loadFnOpt field@(Field { fieldDefault = Just def }) expr o
   = case fieldIsOptional field of
       NotOptional -> [| $expr >>= maybe (return $def) $(parseFn field o) |]
-      _           -> fail $ "Field " ++ fieldName field ++ ":\
-                            \ A field can't be optional and\
-                            \ have a default value at the same time."
+      _           -> fail $ "Field " ++ fieldName field ++ ": " ++
+                            "A field can't be optional and " ++
+                            "have a default value at the same time."
 loadFnOpt field expr o
   = [| $expr >>= maybe (return Nothing) (liftM Just . $(parseFn field o)) |]
 
@@ -436,7 +440,12 @@ strADTDecl :: Name -> [String] -> Dec
 strADTDecl name constructors =
   DataD [] name []
           (map (flip NormalC [] . mkName) constructors)
-          [''Show, ''Eq, ''Enum, ''Bounded, ''Ord]
+          [''Show, ''Eq, ''Enum, ''Bounded, ''Ord
+#if MIN_VERSION_base(4,6,0)
+          , ''Generic
+#else
+#endif
+          ]
 
 -- | Generates a toRaw function.
 --
@@ -606,8 +615,8 @@ reifyConsNames name = do
   reify_result <- reify name
   case reify_result of
     TyConI (DataD _ _ _ cons _) -> mapM (liftM nameBase . constructorName) cons
-    o -> fail $ "Unhandled name passed to reifyConsNames, expected\
-                \ type constructor but got '" ++ show o ++ "'"
+    o -> fail $ "Unhandled name passed to reifyConsNames, expected " ++
+                "type constructor but got '" ++ show o ++ "'"
 
 -- | Builds the generic constructor-to-string function.
 --
@@ -944,8 +953,8 @@ buildObject :: String -> String -> [Field] -> Q [Dec]
 buildObject sname field_pfx fields = do
   when (any ((==) AndRestArguments . fieldIsOptional)
          . drop 1 $ reverse fields)
-    $ fail "Objects may have only one AndRestArguments field,\
-           \ and it must be the last one."
+    $ fail $ "Objects may have only one AndRestArguments field, " ++
+             "and it must be the last one."
   let name = mkName sname
   fields_d <- mapM (fieldTypeInfo field_pfx) fields
   let decl_d = RecC name fields_d
diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs
index 52c30f1..0a6bdd0 100644
--- a/src/Ganeti/Types.hs
+++ b/src/Ganeti/Types.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TemplateHaskell, DeriveFunctor #-}
+{-# LANGUAGE TemplateHaskell, DeriveFunctor, DeriveGeneric #-}
 
 {-| Some common Ganeti types.
 
-- 
2.5.0.457.gab17608

Reply via email to