When working with monadic expressions in Haskell, the use of liftM
's (even in infix position) often seems quite unaesthetic and verbose to me.
Most other monadic primitives (>>=
, >>
) and even liftM
's pure pendant $
are infix operators. This makes me think why there is no operator symbol for monadic lifting.
Do you have reasonable, consistent suggestions for an operator symbol (or why there shouldn't be one)?
(I thought of >-
and -<
(shifting the monad through a function), but they seem to have different meanings in the context of arrows.)
You can use the <$>
operator from Control.Applicative.
EDIT: Unfortunately <$>
only works for some Monads which are instances of Applicative. Defining some instance Monad m => Applicative m
is not possible as this would overlap with the existing Applicative instances IO, Maybe and [].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With