Shooting from the comonad store

In the past few weeks, I have contributed to a library in which monads of ports (mainly from mtl) to shooters.

Here is an example with a monad StateTfrom mtl:

newtype StateT s m a = StateT { runStateT :: s -> m (a, s) }
-- arrowization -->
newtype StateTA s a b c = StateTA { runStateTA :: a (b, s) (c, s) }

The "shooting" process was not very painful for most monads, but I can not understand my arrow based on Store comonad.

Every time I asked this question, people redirected me to an arrow Cokleisli, but will there be an Cokleisli Storeequivalent arrow that I am looking for?

The library is based on the mtl-style architecture (each arrow has a common class, for example ArrowState, ArrowReaderetc.), I tried to figure out what the signatures of my function will be ArrowStore, but again, I can not.

I looked at a package arrowsthat implements the same arrows as in the library I'm working on, but their arrow CoState(I heard that CoState was a different name for the store) does not define any operations, so I guess the author also has problems with this problem.

TL; DR:

  • Is the Monad m => Kleisli m a barrow version equivalent m?
  • Is this also true for arrow comonads Cokleisli?
  • If so, how can I express Storecomonad as an arrow?
  • If not, can we even “shoot” comonads?
+4
source share
1 answer

leftaroundabout Store comonad.

, " ", , - . , Cokleisli Store, ( , ):

newtype CokleisliT a w b c = CokleisliT { runCokleisliT :: a (w b) c }
newtype Store s a = Store (s -> a, s)

    Arrow a => CokleisliT a (Store s) b c
<=> Arrow a => a (Store s b) c
<=> Arrow a => a (s -> b, s) c

ArrowStore:

class Arrow a => ArrowStore s a | a -> s where
    pos   :: a () s
    peek  :: a () b -> a s b
    peeks :: a () b -> a (s -> s) b
    seek  :: a (s, b) c -> a b c
    seeks :: a (s, b) c -> a (s -> s, b) c

, , -, (co) () .

: https://github.com/felko/atl.

+4

Source: https://habr.com/ru/post/1657296/


All Articles