<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Johannes,<div class=""><br class=""></div><div class="">The lens library defines (<&>) with very low precedence (1), whereas (<$>) has precedence 4. If you define (<&>) yourself and specify a precedence higher than 4, or just don’t specify a precedence at all, your example will work fine:</div><div class=""><br class=""></div><div class=""><div class="">(<&>) :: Functor f => f a -> (a -> b) -> f b</div><div class="">(<&>) = flip fmap</div></div><div class=""><br class=""></div><div class="">"foo" <**> "bar" <&> (,)</div><div class=""><br class=""></div><div class="">You can do hanging style too, with no dollar sign:</div><div class=""><br class=""></div><div class=""><div class="">"foo" <**> "bar" <&> \q r -></div><div class="">..(q, r)</div></div><div class=""><br class=""></div><div class="">If you don’t like defining ad-hoc versions of things like (<&>), you might find the ‘overhang’ library useful: <a href="https://hackage.haskell.org/package/overhang-1.0.0/docs/Overhang.html#v:onMap" class="">https://hackage.haskell.org/package/overhang-1.0.0/docs/Overhang.html#v:onMap</a></div><div class=""><br class=""></div><div class="">The overhang equivalent of (<&>) is ‘onMap’ and it can be used in the same way:</div><div class=""><br class=""></div><div class=""><div class="">import Overhang (onMap)</div><div class=""><br class=""></div><div class="">"foo" <**> "bar" `onMap` (,)</div></div><div class=""><br class=""></div><div class="">The code aesthetics around writing a “final" lambda that spans several lines was the driver for creating that library!</div><div class=""><br class=""></div><div class="">Jason<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 6, 2018, at 12:37 PM, Neil Mayhew <<a href="mailto:neil_mayhew@users.sourceforge.net" class="">neil_mayhew@users.sourceforge.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 2018-02-06 07:59 AM, MarLinn wrote:<br class=""><blockquote type="cite" class="">I've been bitten multiple times because of my own invented operators. What was (>>?!) again? Or (^>>>&)? The more I use Haskell the more I tend to solutions like that first dead-simple one.<br class=""></blockquote><br class="">I agree.<br class=""><br class="">Also, since<br class=""><br class="">func <$> "foo" <*> "bar"<br class=""><br class="">is the lifted equivalent of<br class=""><br class="">func "foo" "bar"<br class=""><br class="">I find it unintuitive to read or write the logic in the opposite order.<br class=""><br class="">Whether we like it or not, Haskell is fundamentally a right-to-left language. Or, to look at it another way, top-down corresponds to left-to-right, and bottom-up corresponds to right-to-left. Perhaps it depends on whether you're a top-down thinker (like me) or a bottom-up thinker. I much prefer `where` to `let`, for example.<br class="">_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br class=""></div></body></html>