1

I need a function with type Pipe a b m r -> Pipe (a, c) (b, c) m r.

But no matter how much I play with for, ~> or >~; I can not match the types properly.

Can you help me?

utdemir
  • 26,532
  • 10
  • 62
  • 81

1 Answers1

4

I don't think it's possible in general. Suppose we did manage to write it:

hypotheticalLift :: Pipe a b m r -> Pipe (a, c) (b, c) m r

What behavior should hypotheticalLift (yield b) have? Presumably it should be the same as yield (b, c) for some c -- but which c, and why?

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Sorry, I don't understand your point. I was expecting `hypotheticalLift` to just pass the second argument of the tuple as-is. It does not need to generate `c`, just like `Control.Arrow.first`. – utdemir Dec 26 '16 at 10:41
  • 3
    That means it would have to consume one `c` from upstream for each `c` sent downstream. When you want to `yield` a `b`, do you put it into a queue that might become arbitrarily large until `await`ing an `a` gives you a `c` as a side effect, or do you immediately `await` and put the `a` into a queue until you need it? When you `await` an `a`, do you put the accompanying `c` into a queue that might become arbitrarily large? – Gurkenglas Dec 26 '16 at 12:34
  • @Gurkenglas , oh, now I understand that. Thank you. – utdemir Dec 26 '16 at 22:43