+
+dictSelRule :: Int -> Arity -> [CoreExpr] -> Maybe CoreExpr
+-- Oh, very clever
+-- op_i t1..tk (df s1..sn d1..dm) = op_i_helper s1..sn d1..dm
+-- op_i t1..tk (D t1..tk op1 ... opm) = opi
+--
+-- NB: the data constructor has the same number of type args as the class op
+
+dictSelRule index n_ty_args args
+ | (dict_arg : _) <- drop n_ty_args args
+ , Just (_, _, val_args) <- exprIsConApp_maybe dict_arg
+ = Just (val_args !! index)
+ | otherwise
+ = Nothing