| ```Haskell -- | Flipped version of '<$>'. infixl 1 <&> (<&>) :: Functor f => f a -> (a -> b) -> f b as <&> f = f <$> as ``` "infix", "Functor", and "as" are the only words in this code. Everything else is single letters (thanks math traditions..) and punctuation.
What's a <&>? <$>? ::? We've got two different kinds of arrows, => and ->.
-- is obviously enough a line comment.
At least I know what = means.. give or take it's constant ambiguous meaning between languages of assignment and/or equality testing. And this isn't even delving into the black arts of defining types, where the really ugly punctuation toolkits get opened. I don't care whether or not they represent regular functions nor what their calling syntax is. What I care is that the base language has many many dozens of them to remember and then to parse in the wild, and then that authors are encouraged to continue proliferating more of them: ```Haskell -- What does this 'mouse operator' mean? :thinking_suicide: (~@@^>) :: Functor f => (a -> b) -> (a -> c -> d) -> (b -> f c) -> a -> f d ``` Credit: Kowainik's Haskell Style Guide
https://kowainik.github.io/posts/2019-02-06-style-guide |
in fact the example you picked is trivially simple even if you dont really know the syntax. all you need to do is not rage out and stop thinking. it's literally saying that "as <&> f" is equal to "f <$> as". so you dont even need to know what <$> is, its extremely straightforward that <&> is just flipping the order of the arguments to <$>
also if you read the type signature then there really arent many possible things this function could do. you start with a Functor a and a function that maps from a to b, and you end up with a Functor b. there's really only one possible implementation of that (applying the function (a -> b) to the a in Functor a)
like im curious, what would you even name these things to make it clearer? it's so abstract in generic in the very concept of it that it's hard to come up with any more specific naming
Functor functor => functor someType -> (someType -> someOtherType) -> functor someOtherType
is that better?