简体   繁体   中英

Is there identity conduit?

The title says it all. I've seen that some people apparently use Data.Conduit.List.map id as identity conduit, but is this the recommended way to stream data unchanged?

The simplest way to write an identity conduit is probably:

awaitForever yield

because this doesn't require an extra import.

The definition of Data.Conduit.List.map is very similar:

mapC f = awaitForever $ yield . f

(The difference between mapC and map has something to do with CPP macros to define fusion.)

When optimization is on ( -O1 ), it appears both options result in identical code, so it's just a matter of taste.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM