Repository: thrift Updated Branches: refs/heads/master 19e32dc0e -> b1783a572
THRIFT-3092 Generated Haskell types should derive Generic This closes #437 commit bc922190b70e1264f356ab463dda18babf7910e3 Author: Abhinav Gupta <[email protected]> Date: 2015-03-11T07:26:58Z [haskell] Derive Generic in generated types Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/b1783a57 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/b1783a57 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/b1783a57 Branch: refs/heads/master Commit: b1783a5722e7ab1669f5926c233ea40af0f3c924 Parents: 19e32dc Author: Roger Meier <[email protected]> Authored: Sun Apr 12 22:08:20 2015 +0200 Committer: Roger Meier <[email protected]> Committed: Sun Apr 12 22:08:20 2015 +0200 ---------------------------------------------------------------------- compiler/cpp/src/generate/t_hs_generator.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/b1783a57/compiler/cpp/src/generate/t_hs_generator.cc ---------------------------------------------------------------------- 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 @@ void t_hs_generator::init_generator() { 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 @@ string t_hs_generator::hs_imports() { "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 @@ void t_hs_generator::generate_enum(t_enum* tenum) { 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 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out, 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;
