You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the additional restrictions involved in balancing the shared interface are necessary to equip Proxy with an indexed applicative structure, it seems we don't have any such restrictions for an indexed alternative or indexed align:
dataProxya'ab'bmrwhereFin::r->Proxya'ab'bmrRes:: (b'-> (b, Proxya'ab'bmr)) ->Proxya'ab'bmrReq::a'-> (a->Proxya'ab'bmr) ->Proxya'ab'bmrEff::m (Proxya'ab'bmr) ->Proxya'ab'bmrderivinginstanceFunctorm=>Functor (Proxya'ab'bm)
dataTheseab=Thisa | Thatb | Theseabthese:: (a->b->c) -> (a->c) -> (b->c) ->Theseab->c
these f _ _ (These a b) = f a b
these _ f _ (This a) = f a
these _ _ f (That a) = f a
align::Functorm=>Proxyb'bc'cmr->Proxya'ab'bms->Proxya'ac'cm (Thesers)
Fin r `align`Fin s =Fin$These r s
Fin r `align` _ =Fin$This r
_ `align`Fin r =Fin$That r
Res f `align` y =Res$fmap (`align` y) . f
x `align`Req y f =Req y $ (x `align`) . f
Eff m `align` y =Eff$ (`align` y) <$> m
x `align`Eff m =Eff$ (x `align`) <$> m
Req r f `align`Res g =let (b, v) = g r in f b `align` v
union::Functorm=>Proxyb'bc'cmr->Proxya'ab'bms->Proxya'ab'bm (Eitherrs)
union x y = (these (\x _ ->Left x) LeftRight) align x y
I haven't thought too hard about whether the associativity law works out here, but I feel like it should. The other problem is: what (if anything) is the identity? It seems to me that an "infinite" proxy that never returns would act as the identity for union, since the overall result is the one of the shorter proxy:
@masaeedu: I believe the identity of union would be cat (treating Either Void a as isomorphic to a)
I also think the identity of align would be something like Pipes.take n, where n would be the index used to track how the number of requests/responses at the interface
@Gabriel439 Wouldn't cat :: Monad m => Proxy () a () a m r have the wrong type? We need something of type Proxy a' a a' a m Void.
The second () I just realized we can deal with, because it's in a contravariant position. So for that one we can just map in a discard :: x -> () and get contramapSomewhere discard $ cat :: Monad m => Proxy () a a' a m r. The first () is in a covariant position though, so I don't think we can get rid of it.
In #218 I suggested that "balanced" pipes form an indexed applicative, which in other words is a particular kind of lax monoidal functor:
But there are other sorts of monoidal functors. For example there is
Alternative
:and
Alignable
:While the additional restrictions involved in balancing the shared interface are necessary to equip
Proxy
with an indexed applicative structure, it seems we don't have any such restrictions for an indexed alternative or indexed align:I haven't thought too hard about whether the associativity law works out here, but I feel like it should. The other problem is: what (if anything) is the identity? It seems to me that an "infinite" proxy that never returns would act as the identity for
union
, since the overall result is the one of the shorter proxy:Not sure whether any of the above is right, but I thought I'd share the idea at least.
The text was updated successfully, but these errors were encountered: