流处理器的ArrowCircuit实例可能会阻塞

问题描述

Control.Arrow.Operations.ArrowCircuit类用于:

可用于解释同步电路的箭头类型。

我想知道同步在这里的含义。我在Wikipedia上进行了查询,他们在谈论数字电子。我的电子设备很生锈,所以这里有个问题:所谓的异步流处理器这样的实例有什么问题(如果有的话):

data StreamProcessor a b = Get (a -> StreamProcessor a b) | 
                           Put b    (StreamProcessor a b) |
                           Halt

instance Category StreamProcessor where
    id = Get (\ x -> Put x id)
  
    Put c bc . ab = Put c (bc . ab)
    Get bbc . Put b ab = (bbc b) . ab
    Get bbc . Get aab = Get $ \ a -> (Get bbc) . (aab a)
    Get bbc . Halt = Halt
    Halt . ab = Halt

instance Arrow StreamProcessor where
    ...

getThroughBlocks :: [a] -> StreamProcessor a b -> StreamProcessor a b
getThroughBlocks ~(a : input) (Get f)   = getThroughBlocks input (f a)
getThroughBlocks _input       putOrHalt = putOrHalt

getThroughSameArgBlocks :: a -> StreamProcessor a b -> StreamProcessor a b
getThroughSameArgBlocks = getThroughBlocks . repeat

instance ArrowLoop StreamProcessor where
    loop Halt               = Halt
    loop (Put (c,d) bdcd') = Put c (loop bdcd')
    loop (Get f)            = Get $ \ b -> 
         let 
            Put (c,d) bdcd' = getThroughSameArgBlocks (b,d) (f (b,d))
         in Put c (loop bdcd')

instance ArrowCircuit StreamProcessor where
    delay b = Put b id

我认为此解决方案可以为我们工作,因为:我们希望someArrowCircuit >>> delay b延迟someArrowCircuit一刻,而b会比它延迟任何时间。很容易看到我们得到了我们想要的东西:

someArrowCircuit >>> delay b
= someArrowCircuit >>> Put b id 
= Put b id . someArrowCircuit
= Put b (id . someArrowCircuit)
= Put b someArrowCircuit

此类课程是否有法律?如果我没记错的写下delay同步 如何与 异步并存?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)