Channel: read-only source?

Suppose I have a source keypads :: Producer IO Keypad

that generates a stream of sensitive data like disposable keyboards.

Now if my library provides keypads

, the end user can connect keypads

to two receivers, call them good

and bad

where it bad

asks for the value and reads it, but then it returns it back upstream through leftover

. Later, the receiver good

can use the same keyboard that it previously read bad

. The end user can not pay attention to it, for example, when good

and bad

by third-party libraries.

Is there a way to construct a read-only source in the conduit that discards the remaining data?

(I read here that it is not possible to turn off remnant reuse, but since I am new to conduit, there may be another way of architectural design that I cannot see.)

+3


source to share


1 answer


I can imagine two options:

  • Wrap bad

    with help map id Conduit

    to prevent residues from spreading. I think your code will look something like this:

    keypads $$ (CL.map id =$= bad) >> good
    
          

  • Drop down to the abstraction layer Pipe

    and call injectLeftovers

    on bad

    so that any leftovers there are destroyed and then discarded.



I assume (1) is the approach you need.

+1


source







All Articles