In "Simplicitly: foundations and applications of implicit function types", Odersky et al. briefly introduce the Reader
monad, just to replace it with a superior alternative one paragraph later. This is what the given definition looks like:
trait Reader[R, A] {
def ask: R
def local[A](f: R => R)(a: A): A
}
Thinking that I roughly understand the idea behind Reader
, I've repeatedly glanced over the definition, without actually reading it. But now, while re-reading this paper, I'm just staring at it, struggling to understand what it's trying to tell me. The [A]
after local
, as well as the seemingly completely unconstrained A
in Reader[R, A]
look odd.
Here is what I looked at while trying to figure out what it should have meant:
- The
def local
inobject Reader
inCats
seems perfectly clear: it just precomposes anf: R => R
to aReader[R, A]
, nothing surprising here. - The
Ask
in Cats-MTL has a superficially similar shape, but it's an MTL-style trait describing the capability of a monadF[_]
. In the paper, there is noF[_]
in the first place. - Similarly for
Local
: in the Cats-MTL, it's all about the capabilities of theF[_]
; Also, there is no additional[A]
. - There is the Haskell
MonadReader
typeclass, whoseask
andlocal
signatures look very similar, but again, it's describing the capabilities of a monadm
.
It looks as if the Reader
from the paper combined the definitions of MTL Ask
and Local
, but then removed any mention of the monad that's being described. It's like "MTL", but without the "M" in it - not sure how to interpret it.
- Is it a typo?
- If it is one: does my hypothesis about how this typo occurred seem plausible?
- Are there other closely related definitions that would help make sense of this one?
- There is a "monad instance omitted"-remark right before the code block. Is there some kind of convention about "omitting" all the
M[_]
s andF[_]
s in "the obvious" positions?