genCheckFields' :: String -> [((String,Bool),String)] -> String
genCheckFields' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkFields",name,"(",name,"* s1, ", name,"* s2){\n"]
          names    = map snd types_names
          middle_lines = map (\tp@((_,_),n) -> concat ["    int ",n," = ", as_prim tp, ";\n"]) types_names
              where as_prim ((_,True ),n) = concat ["s1->",n, " == s2->",n]
                    as_prim ((t,False),n) = concat ["checkFields",t,"(&(s1->",n,"),&(s2->",n,"))"]
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " names, ";\n"]
                           else "    return 1; \n"
          last_line = "}\n\n"
genCheckFields' :: String -> [((String,Bool),String)] -> String
genCheckFields' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkFields",name,"(",name,"* s1, ", name,"* s2){\n"]
          names    = map snd types_names
          middle_lines = map (\tp@((_,_),n) -> concat ["    int ",n," = ", as_prim tp, ";\n"]) types_names
              where as_prim ((_,True ),n) = concat ["s1->",n, " == s2->",n]
                    as_prim ((t,False),n) = concat ["checkFields",t,"(&(s1->",n,"),&(s2->",n,"))"]
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " names, ";\n"]
                           else "    return 1; \n"
          last_line = "}\n\n"
genCheckFields' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkFields",name,"(",name,"* s1, ", name,"* s2){\n"]
          names    = map snd types_names
          middle_lines = map (\tp@((_,_),n) -> concat ["    int ",n," = ", as_prim tp, ";\n"]) types_names
              where as_prim ((_,True ),n) = concat ["s1->",n, " == s2->",n]
                    as_prim ((t,False),n) = concat ["checkFields",t,"(&(s1->",n,"),&(s2->",n,"))"]
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " names, ";\n"]
                           else "    return 1; \n"
          last_line = "}\n\n"