I’ve seen this type before without knowing what it means. Does it mean something
and/or does it have a name?
Prelude> :m Data.Functor
Prelude Data.Functor> :t flip . (flip (<$>))
flip . (flip (<$>))
:: Functor ((->) b) => (b -> a) -> b -> (a -> c) -> c
To add to Matt Fenwick and josefg’s more technical answers, the
((->) acan be read as the type constructor that forms values that depend on ana. One example: suppose you have teams whose membership varies over time. One possible way to represent this is like this:((->) a)is aFunctor,ApplicativeandMonad, which means that the type class operations are available, and they have very useful interpretations when used withHistorical t.First example:
fmapapplies a function to a time-dependent value. So for example,The Applicative
<*>operation gives you simultaneity:Though actually, since we have
instance Monoid [a]andinstance Monoid m => Monoid t -> m, the previous example can be written like this:Monad gives you composition:
Note also that
((->) ris exactly the same as theReader rmonad. If you understand the code above you pretty much understandReader.EDIT: I should clarify that time-dependent values is just one use of the function/Reader monad. There are other uses; the classic example use case of the Reader monad is to thread configuration values through a computation. It’s got rather more uses than just that, as the example above shows.