genCheckOffsets' :: String -> [((String,Bool),String)] -> String
genCheckOffsets' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkOffsets",name,"(HsInt16 *offs){\n"]
          names_ixs = zip (map snd types_names) (map show [0,1..])
          middle_lines = map (\(n,i) -> concat ["    int ",n," = offsetof(",name,", ",n,") == offs[",i,"];\n"]) names_ixs
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " $ map snd types_names, ";\n"]
                           else "    return 1;\n"
          last_line    = "}\n\n"
genCheckOffsets' :: String -> [((String,Bool),String)] -> String
genCheckOffsets' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkOffsets",name,"(HsInt16 *offs){\n"]
          names_ixs = zip (map snd types_names) (map show [0,1..])
          middle_lines = map (\(n,i) -> concat ["    int ",n," = offsetof(",name,", ",n,") == offs[",i,"];\n"]) names_ixs
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " $ map snd types_names, ";\n"]
                           else "    return 1;\n"
          last_line    = "}\n\n"
genCheckOffsets' name types_names = concat [fst_line, concat middle_lines, prelst_line, last_line]
    where fst_line = concat ["int checkOffsets",name,"(HsInt16 *offs){\n"]
          names_ixs = zip (map snd types_names) (map show [0,1..])
          middle_lines = map (\(n,i) -> concat ["    int ",n," = offsetof(",name,", ",n,") == offs[",i,"];\n"]) names_ixs
          prelst_line  = if length types_names > 0
                           then concat ["    return ",concat $ intersperse " && " $ map snd types_names, ";\n"]
                           else "    return 1;\n"
          last_line    = "}\n\n"