THRIFT-3092 Generated Haskell types should derive Generic
This closes #437
commit bc922190b70e1264f356ab463dda18babf7910e3
Author: Abhinav Gupta <mail@abhinavg.net>
Date: 2015-03-11T07:26:58Z
[haskell] Derive Generic in generated types
diff --git a/compiler/cpp/src/generate/t_hs_generator.cc b/compiler/cpp/src/generate/t_hs_generator.cc
index b217ce6..638cc30 100644
--- a/compiler/cpp/src/generate/t_hs_generator.cc
+++ b/compiler/cpp/src/generate/t_hs_generator.cc
@@ -205,6 +205,7 @@
string t_hs_generator::hs_language_pragma() {
return string(
"{-# LANGUAGE DeriveDataTypeable #-}\n"
+ "{-# LANGUAGE DeriveGeneric #-}\n"
"{-# LANGUAGE OverloadedStrings #-}\n"
"{-# OPTIONS_GHC -fno-warn-missing-fields #-}\n"
"{-# OPTIONS_GHC -fno-warn-missing-signatures #-}\n"
@@ -241,6 +242,7 @@
"import qualified Data.Maybe as M (catMaybes)\n"
"import qualified Data.Text.Lazy.Encoding as E ( decodeUtf8, encodeUtf8 )\n"
"import qualified Data.Text.Lazy as LT\n"
+ "import qualified GHC.Generics as G (Generic)\n"
"import qualified Data.Typeable as TY ( Typeable )\n"
"import qualified Data.HashMap.Strict as Map\n"
"import qualified Data.HashSet as Set\n"
@@ -302,7 +304,7 @@
f_types_ << name;
first = false;
}
- indent(f_types_) << "deriving (P.Show,P.Eq, TY.Typeable, P.Ord, P.Bounded)" << endl;
+ indent(f_types_) << "deriving (P.Show, P.Eq, G.Generic, TY.Typeable, P.Ord, P.Bounded)" << endl;
indent_down();
string ename = capitalize(tenum->get_name());
@@ -555,7 +557,7 @@
indent_down();
}
- out << " deriving (P.Show,P.Eq,TY.Typeable)" << endl;
+ out << " deriving (P.Show,P.Eq,G.Generic,TY.Typeable)" << endl;
if (is_exception)
out << "instance X.Exception " << tname << endl;