ApplicativeDo should use a more accurate cost model
Motivation
It currently assumes that each statement has the same cost. This is fine if each statement actually DOES have a similar cost, but there is already a much more sophisticated cost model in GHC.
Proposal
Two independent approaches seem useful.
-
The cost could be computed using the cost model the inliner uses. While it is not perfect, either, it is likely to be more accurate overall than the current situation.
-
Annotations could be provided to document the "effect cost" of an effectful function. For example, in a logging effect which has three operations - appending to a buffer, appending to a file, and sending a message over a network connection - could have different costs manually annotated.