ContT monad transformer has an interesting property: if there is a * -> * , such as Set , which has clearly defined monadic operations, but cannot have a Monad instance due to some restrictions (here Ord a ), you can wrap it in ContT ( ContT r Set ) to get an instance of the monad, and set aside constraints outside it, for example, when we insert Set into the ContT r Set . See Building Effective Monad Instances on Set by Continuing the Monad .
Is there something similar for arrows? A converter that will allow you to wrap an “almost arrow” in it, get a valid Arrow instance and postpone problem restrictions for the part where we insert an “almost arrow” into it?
For example, if we had the type AlmostArrow :: * -> * -> * , for which we would have the usual Arrow operations, but with restrictions such as
arr' :: (Ord a, Ord b) => (a -> b) -> AlmostArrow ab (>>>') :: (Ord a, Ord b, Ord c) => AlmostArrow ab -> AlmostArrow bc -> AlmostArrow ac
As a bonus, if so, is there any excellent, general method of category theory, how to get both ContT and such an arrow transformer?
haskell continuations category-theory arrows monad-transformers
Petr pudlák
source share