THRIFT-2647 compiler-hs: don't decapitalize field names, do decapitalize argument bindings

Client: Haskell
Patch: John Chee
diff --git a/compiler/cpp/src/generate/t_hs_generator.cc b/compiler/cpp/src/generate/t_hs_generator.cc
index 133c62e..34479b6 100644
--- a/compiler/cpp/src/generate/t_hs_generator.cc
+++ b/compiler/cpp/src/generate/t_hs_generator.cc
@@ -604,7 +604,7 @@
     generate_deserialize_field(out, *f_iter,str);
     out << endl;
 
-    string fname = decapitalize((*f_iter)->get_name());
+    string fname = (*f_iter)->get_name();
     indent(out) << "read_" << sname << "_fields iprot record{f_" << sname << "_" << fname << "=P.Just s}" << endl;
 
     indent(out) << "else do" << endl;
@@ -638,7 +638,7 @@
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     out << (first ? "" : ",");
-    out << "f_" << sname << "_" << decapitalize((*f_iter)->get_name()) << "=P.Nothing";
+    out << "f_" << sname << "_" << (*f_iter)->get_name() << "=P.Nothing";
     first = false;
   }
 
@@ -882,7 +882,7 @@
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
       string fieldname = (*fld_iter)->get_name();
       f_client_ << (first ? "" : ",");
-      f_client_ << "f_" << argsname << "_" << fieldname << "=P.Just arg_" << fieldname;
+      f_client_ << "f_" << argsname << "_" << fieldname << "=P.Just arg_" << decapitalize(fieldname);
       first = false;
     }
     f_client_ << "})" << endl;
diff --git a/test/NameConflictTest.thrift b/test/NameConflictTest.thrift
index da47a63..ad333eb 100644
--- a/test/NameConflictTest.thrift
+++ b/test/NameConflictTest.thrift
@@ -21,6 +21,25 @@
 	1: using using
 }
 
+enum Maybe {
+  JUST = 1,
+  TRUE = 2,
+  FALSE = 3
+}
+
+enum Either {
+  LEFT = 1,
+  RIGHT = 2
+}
+
+struct foldr {
+  1: string id
+}
+
+struct of {
+  1: string let
+  2: string where
+}
 
 
 struct ClassAndProp {
@@ -78,4 +97,8 @@
 	void Foo(1: Nested Foo_args) throws (1: Problem_ Foo_result)
 }
 
+service qualified {
+	Maybe maybe(1: Maybe foldr)
+	Either either(1: foldr of)
+}
 // eof
diff --git a/test/hs/Makefile.am b/test/hs/Makefile.am
index e948b41..2e016c4 100644
--- a/test/hs/Makefile.am
+++ b/test/hs/Makefile.am
@@ -19,17 +19,19 @@
 
 THRIFT = $(top_srcdir)/compiler/cpp/thrift
 
-stubs: ../ConstantsDemo.thrift ../DebugProtoTest.thrift ../ThriftTest.thrift ../Include.thrift
+stubs: ../ConstantsDemo.thrift ../DebugProtoTest.thrift ../ThriftTest.thrift ../Include.thrift ../NameConflictTest.thrift
 	$(THRIFT) --gen hs ../ConstantsDemo.thrift
 	$(THRIFT) --gen hs ../DebugProtoTest.thrift
 	$(THRIFT) --gen hs ../ThriftTest.thrift
 	$(THRIFT) --gen hs ../Include.thrift
+	$(THRIFT) --gen hs ../NameConflictTest.thrift
 
 check: stubs
 	sh run-test.sh ConstantsDemo
 	sh run-test.sh DebugProtoTest
 	sh run-test.sh ThriftTest
 	sh run-test.sh Include
+	sh run-test.sh NameConflictTest
 
 clean-local:
 	$(RM) -r gen-hs
diff --git a/test/hs/NameConflictTest_Main.hs b/test/hs/NameConflictTest_Main.hs
new file mode 100644
index 0000000..5d0b17a
--- /dev/null
+++ b/test/hs/NameConflictTest_Main.hs
@@ -0,0 +1,19 @@
+module Main where
+
+import qualified Prelude as P
+
+import NameConflictTest_Consts
+import NameConflictTest_Types
+import Qualified
+import Qualified_Client
+import Qualified_Iface
+import Extern
+import Extern_Client
+import Extern_Iface
+
+main :: P.IO ()
+main = do
+  P.putStrLn "Values:"
+  P.print ([JUST, TRUE, FALSE] :: [Maybe])
+  P.print ([LEFT, RIGHT] :: [Either])
+  P.print (Problem_ (P.Just P.True) (P.Just P.False))