Stack’s code makes a lot of use of base
's when :: Applicative f => Bool -> f () -> f ()
. I wondered if there was a Applicative f => Maybe a -> (a -> f()) -> f ()
and Hoogle found whenJust
from extra
(already a dependency of Stack). So:
case mSomething of
Nothing -> pure ()
Just value -> do
complicatedActionWith value
can become:
whenJust mSomething $ \value -> do
complicatedActionWith value
Which, for me, is a more expressive syntax. My question is: Is there any downside with replacing the former form with the latter form? The former form appears a lot in Stack’s code.
EDIT: I suppose what I am really asking is: Can I safely assume that the compiler does not care, one way or the other?