Haskell Pipes and Branching

后端 未结 2 1048
轮回少年
轮回少年 2021-01-02 05:51

Problem

I\'m attempting to implement a simple web server with Haskell and the Pipes library. I understand now that cyclic or diamond topologies aren\'t possible wi

2条回答
  •  一向
    一向 (楼主)
    2021-01-02 06:18

    I have not run your code, but I think I spotted a problem.

    routeRequest'' = runProxyK $ routeRequest''' <-< unitU
    

    routeRequest''' is requesting data from unitU which has nothing to supply, so it hangs.

    :t runProxy $ unitU >-> printD
    

    Will type check but nothing runs.

    It seems like the data is being sent to the wrong level of the monad transformer, data which is flowing into routeRequest should be flowing into routeRequest'''. The data flowing into the wrong level of the monad transformer is what is probably causing you to need to leave of the type signature to get everything to type check. With the type signature routeRequest is expecting a () coming from upstream and, I bet, with no type signature it is allowed to be polymorphic.

    In your definition of routeRequest you could "close the pipe", I think that is what it is called, by using unitD which would disallow your construction even when routeRequest''' does not have the type signature.

提交回复
热议问题