<$> and fmap

Hi, newbie question, I have the following code which works but I’m not clear on what it is doing:

condObligation <- Some <$> create (fromSome paymentObligation)

where paymentObligation is an optional field on my template. Please could I get a steer on what <$> does and why it is needed. I have looked at the documentation which says it is a synonym for fmap but if I replace <$> with fmap I get an error. Is there a way to achieve the same result using fmap instead of <$> please? Thanks!

The difference between fmap and <$> is that fmap is a regular function while <$> is an infix operator. so to use fmap here use it like you use a regular function:

condObligation <- fmap Some (create (fromSome paymentObligation))

Alternatively you can also turn any function into an infix operator by wrapping it in backticks:

condObligation <- Some `fmap` create (fromSome paymentObligation)

You can also go the other way around and wrap infix operators in parentheses to turn them into (prefix) function?d

condObligation <- (<$>) Some (create (fromSome paymentObligation))

Of course, that makes perfect sense, thank you.