1

I seem unable to find where two relatively simple Haskell methods are defined.

It's about ReaderT. I am looking for its implementation of ask and local, as requested by the MonadReader contract.

At https://hackage.haskell.org/package/mtl-2.1.2/docs/src/Control-Monad-Reader-Class.html#ask I read:

instance Monad m => MonadReader r (ReaderT r m) where
  ask = ReaderT.ask
  local = ReaderT.local

but then I cannot find neither ReaderT.ask nor ReaderT.local anywhere.

It is the first time that I find no implementation by perusing Hackage.

Am I missing something?

Marco Faustinelli
  • 3,734
  • 5
  • 30
  • 49

1 Answers1

1

That file contains the import statement

import qualified Control.Monad.Trans.Reader as ReaderT (ask, local, reader)

so ReaderT.ask etc. refer to that module, from the transformers-0.3.0.0 package (the only listed dependency of mtl-2.1.2. If you look on the main Hackage page of each package you may note that these are not the newest versions of either package.)

In general, transformers and mtl define many functions of the same name, except that the transformers versions work only on the transformer type directly implementing the relevant effect, while mtl uses the Monad* class system to make them methods that can lift automatically to other, wrapping transformers.

For the directly implementing transformer, like in your case, the particular method instance used in mtl is usually just refering to the corresponding transformer function.

Ørjan Johansen
  • 18,119
  • 3
  • 43
  • 53