Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:25:54+00:00 2026-05-29T06:25:54+00:00

Pipes are a really elegant, really simple version of iteratees. You can write pipe

  • 0

Pipes are a really elegant, really simple version of iteratees. You can write pipe code very easily using the primitives await and yield. Paolo Capriotti extended the concept of pipes with guarded pipes, which uses the slightly more complicated tryAwait primitive, which allows a pipe to perform some finalization once the input flow runs out.

The guarded pipe implementation redefines await in terms of tryAwait:

await = tryAwait >>= maybe discard return

My question is this: if I write code targeted at the simpler Pipes implementation (using await and yield), using the same code, will it behave the same if I switch over to the guarded pipe implementation? In other words, can guarded pipe code be treated as simply a superset of pipe code, in terms of behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:25:54+00:00Added an answer on May 29, 2026 at 6:25 am

    This is Gabriel, who posted Pipes. I’ve been working with Paolo and we have a more elegant implementation in the works that is even more powerful and typesafe than his original proposal. The short answer to your question is that the final implementation is a superset of the original Pipes and you can write the same code as before with identical behavior and semantics.

    I can even summarize it pretty simply here. Await and yield statements are the only ways a pipe can give up control, so we attach to each one a fallback if the upstream or downstream pipe terminates. The fallback downgrades a pipe permanently and it can no longer repeat the failed action. A failed await downgrades a pipe to a producer and a failed yield downgrades a pipe to a consumer. If a producer fails to yield or a consumer fails to await, they are downgraded to the base monad, which can no longer fail.

    Consumers and producers are now separate types and the are not exposed. They are the same as the type pipe type except missing the Await or Yield constructor. This is necessary, at least for the producer type, since there is no input type for pipes that can prohibit await statements.

    Await and yield statements default to termination as their fall back behavior, which is the same behavior as before. Await and yield will be typeclassed to work in downgraded states that support them. However you can now optionally provide your own fallback as soon as we come up with a sexier name than tryAwait or tryYield.

    I have to still verify that Pipes still form a category with this extension, but it seems very likely. It’s also 100% typesafe and uses the types to enforce the downgrade rather than booleans and a programmer proven invariant.

    Edit: Some functioning code to whet your appetite (Checkout the “try” branch from the github repository to use the extension):

    printer = forever $ await >>= lift . print
    
    take' n = replicateM_ n $ await >>= yield
    
    fromList' = mapM_ (yieldOr (lift $ putStrLn "Undelivered elements))
    
    diagnose = forever $ do
        x <- awaitOr (lift $ putStrLn "Await failed")
        yieldOr (lift $ putStrLn "Yield failed") x
    
    > runPipe $ printer <+< take' 3 <+< diagnose <+< fromList [1..10]
    1
    2
    3
    Yield failed
    Undelivered elements
    > runPipe $ printer <+< take' 10 <+< diagnose <+< fromList [1..3]
    1
    2
    3
    Await failed
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write some code which uses pipes to communicate between a parent
Can pipes be used across LAN computers? In particular I'm looking for Windows, but
Why are pipes considered dangerous to use? What can be done to avoid these
I remember using Named Pipes for communicating between 2 machines (back in Windows NT).
I'm using Linq2Sql with pipes/filters. My database consists of Accounts and Transactions tables where
Yahoo Pipes are a very intriguing choice for sort of a poor-man's server-free ETL
I have an apparently simple regex query for pipes - I need to truncate
Im trying to use http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/ as inspiration, but I'm having some troubles with the
I'm working on a new version of an already released code of perl, and
i've got this snazzy python code: import subprocess value = subprocess.Popen([php,./php/php_runner.php],stdout=subprocess.PIPE); the problem is,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.