- relevant_eq_op = assoc_ty_id eq_op_tbl ty
- relevant_lt_op = assoc_ty_id lt_op_tbl ty
-
-assoc_ty_id tyids ty
- = if null res then panic "assoc_ty"
- else head res
+ relevant_eq_op = assoc_ty_id "Ord" tycon eq_op_tbl ty
+ relevant_lt_op = assoc_ty_id "Ord" tycon lt_op_tbl ty
+
+
+box_if_necy :: String -- The class involved
+ -> TyCon -- The tycon involved
+ -> RdrNameHsExpr -- The argument
+ -> Type -- The argument type
+ -> RdrNameHsExpr -- Boxed version of the arg
+box_if_necy cls_str tycon arg arg_ty
+ | isUnLiftedType arg_ty = HsApp (HsVar box_con) arg
+ | otherwise = arg
+ where
+ box_con = assoc_ty_id cls_str tycon box_con_tbl arg_ty
+
+assoc_ty_id :: String -- The class involved
+ -> TyCon -- The tycon involved
+ -> [(Type,a)] -- The table
+ -> Type -- The type
+ -> a -- The result of the lookup
+assoc_ty_id cls_str tycon tbl ty
+ | null res = pprPanic "Error in deriving:" (text "Can't derive" <+> text cls_str <+>
+ text "for primitive type" <+> ppr ty)
+ | otherwise = head res