Open sjakobi opened 6 years ago
Generally speaking, they're helpful in in higher-order contexts when there might not be enough inlining to avoid problems. f . coerce
or coerce . f
can potentially build a closure that just passes an argument to f
, while coerce #. f
and f .# coerce
are really just f
. The reason is that if GHC can't see that f
has arity at least 1, then f
and the dotted version could actually be different. This tends only to be a problem when f
is totally unknown and the HOF doesn't inline. So it usually won't matter, but sometimes can.
This seems to be the main selling point of the operators.
We should add some benchmarks and summarize the results in the docs.