I’m currently writing code where
foo :: Monad m => (m a -> m a) -> m a -> m a
foo kv m = m >>= kv . return
occurs a lot as a partial application foo kv
(currently inline as (>>= kv . return) $ ...
).
foo kv m
is not the same as kv m
; the latter performs effects in kv
before performing effects in m
and it is crucial for my use case to “squeeze dry” m
of any effects before calling kv
.
I can’t restrict kv
to the more specific type a -> m a
; so simply bind = flip (>>=)
and writing bind kv $ ...
is not an option.
So what would be an appropriate or established name for foo
? It’s kind of like call-by-value, but for effects. (Of course it is nothing like actual call-by-value, because the a
is not necessarily evaluated.)