Skip to content

Instantly share code, notes, and snippets.

@berewt
Created February 8, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berewt/3e318dc69f8939f1b2ea15bccbbac436 to your computer and use it in GitHub Desktop.
Save berewt/3e318dc69f8939f1b2ea15bccbbac436 to your computer and use it in GitHub Desktop.
module Pipes.ITE where
import Pipes
import qualified Pipes.Prelude as P
ite :: Monad m => (a -> Bool) -> Pipe a b m () -> Pipe a c m () -> Pipe (Either b c) d m () -> Pipe a d m r
ite predicate l r j = for cat $ \x -> yield x >-> if predicate x
then l >-> P.map Left >-> j
else r >-> P.map Right >-> j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment