phischu
phischu

Reputation: 440

Is there a free proxy transformer?

Do you think a free proxy transformer is possible? Something like

data FreePT f p a' a b' b m r = ....

instance (Proxy p,Functor f) => Proxy (FreePT f p) where
    ....

instance (Functor f) => ProxyTrans (FreePT f) where
    ....

This is not only curiosity I would actually find this useful.

Upvotes: 7

Views: 415

Answers (1)

Gabriella Gonzalez
Gabriella Gonzalez

Reputation: 35099

This isn't an answer, but it won't fit within a comment.

I've wanted a similar functionality, too. I suspect the internal type will look like this:

-- The same `FreeF` type from the `free` package in `Control.Monad.Trans.Free`
data FreeF f a x = Pure a | Free (f x)

newtype FreeP f p a' a b' b m r
    = FreeP { unFreeP ::
        p a'
          (FreeF f a (FreeP f p a' a b' b m r))
          b'
          (FreeF f b (FreeP f p a' a b' b m r))
          m
          (FreeF f r (FreeP f p a' a b' b m r)) }

Also, it might not be possible with the currently existing machinery, but that is okay. For example, consult the StateP proxy transformer, which relies on thread_P from ProxyInternal. A similar analog to thread_P might be necessary to implement FreeP.

Upvotes: 2

Related Questions