Exemplo n.º 1
0
class DiscardL(IO, InfixMix()):
    op = ">>"
    def do(self):
        result = self.left.do()
        if isinstance(result, IOZeroType):
            return result
        return self.right.do()
Exemplo n.º 2
0
class Bind(IO, InfixMix()):
    op = "&"
    def do(self):
        result = self.left.do()
        if isinstance(result, IOZeroType):
            return result
        return self.right(result).do()
Exemplo n.º 3
0
class Or(IO, InfixMix()):
    op = "|"
    def do(self):
        result = self.left.do()
        if isinstance(result, IOZeroType):
            return self.right.do()
        return result    
Exemplo n.º 4
0
class Apply(IO, InfixMix()):
    op = "*"
    def do(self):
        f = self.left.do()
        if isinstance(f, IOZeroType):
            return f
        x = self.right.do()
        if isinstance(x, IOZeroType):
            return x
        return f(x)
Exemplo n.º 5
0
class ProcessorComposite(Processor, InfixMix()):
    op = ">>"
    __init__ = InfixMix().__init__

    def __call__(self, stream):
        return self.right(self.left(stream))