Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inventing a suitable infix operator symbol for liftM

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.)

like image 791
Dario Avatar asked Dec 29 '22 10:12

Dario


1 Answers

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 [].

like image 160
Long Avatar answered Jan 12 '23 20:01

Long