Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 696
phischu Avatar asked May 16 '13 16:05

phischu


1 Answers

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.

like image 87
Gabriella Gonzalez Avatar answered Nov 13 '22 21:11

Gabriella Gonzalez