In https://hackage.haskell.org/package/category-extras-0.53.0/docs/Control-Comonad-Reader.html, the co-reader monad is defined, and the co-monadic type modality applies to a type a
and generates a pair (r,a)
. The comonadic type modality w
is therefore of type a -> (r, a)
.
This is quite different from the reader monad, in which the monadic type modality applies to a type a and generates a function of type r -> a
, for a particular type r
.
It is not clear to me why the co-monadic modality is not defined in a way analogous to the reader modality, so that, where w
is the relevant co-monadic modality, we have w a := r -> a
, and then the functions extract :: w a -> a
and (<<=) :: (w a -> b) -> w a -> w b
merely rearrange return :: a -> m a
and bind (=<<) :: (a -> m b) -> m a -> m b
, respectively (where m a : = r -> a
).
This is to say, can the co-reader monad be defined analogously to the reader monad, except that we change the direction of the arrows? Is changing the arrows of bind and of return sufficient to generate (a (?)) co-reader monad? If not, then why not.
Furthermore, would it be possible to define a comonadic modality w
as w a := r -> a
, together with the functions extract :: w a -> a
and (<<=) :: (w a -> b) -> w a -> w b
?
Edit: this question has been totally rewritten in response to an objection that it was unclear.
(e -> a) -> a
, while it's easy to implement(e, a) -> a
(withsnd
) and its curried varianta -> ( e -> a)
(withconst
). We can't take the same functor from the monad and make it into a comonad. We need the left adjoint, which is provided by (un)currying. – chir->e
but nor
, there's no way for you to construct ae
. More in general, the proposition(A->B)->B
isn't an intuitionistic tautology (nor a classical one), so by Curry-Howard it can't be implemented. – chi