Skip to content

Conversation

@echatav
Copy link
Contributor

@echatav echatav commented Nov 17, 2025

Optimization via Cayley representation of Atkey indexed monad transformers.

Comment on lines +87 to +89
newtype CodensityIx t i j m a = CodensityIx
{ runCodensityIx :: forall b k. (a -> t j k m b) -> t i k m b }
deriving Functor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indexed codensity monad transformer type which I found in sessiontypes by @Ferdinand-vW.

Comment on lines +169 to +180
instance IxMonadTransReader t => IxMonadTransState (CodensityIx t) where
putIx s = CodensityIx (localIx (const s) . ($ ()))
instance (s ~ t, Monad m, IxMonadTransFree freeIx)
=> MonadReader s (freeIx (Ixer AskIx) s t m) where
ask = liftFreerIx AskIx
local = localIx
instance IxMonadTransFree freeIx
=> IxMonadTransReader (freeIx (Ixer AskIx)) where
localIx f
= lowerCodensityIx
. (\m -> Ix.do {i <- get; putIx (f i); m})
. liftCodensityIx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is broken. putIx and localIx reference one another and cause an inf-loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants