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 956737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:35:14+00:00 2026-05-16T00:35:14+00:00

We all love do , and I was curious if perhaps this sort of

  • 0

We all love do, and I was curious if perhaps this sort of alternate syntax would theoretically be useful outside of the monad world. If so, what other sorts of computations would it simplify? Would it make sense to have something equivalent for Applicative, for example?

  • 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-16T00:35:14+00:00Added an answer on May 16, 2026 at 12:35 am

    It might help to consider, regarding do notation itself, what it’s actually good for. As Travis Brown points out, I’ve previously advocated the use of a “function application” style with Monads and related types, but there’s a flip side to that as well: Some expressions simply can’t be written cleanly in direct function application style. For instance, the following can quickly make applicative style clumsy:

    • Intermediate results used in multiple subexpressions, at different depths of nesting
    • Arguments to the outermost function used deeply-nested in subexpressions
    • Awkward or inconsistent argument order, i.e. needing to partially apply a function to something other than its first argument
    • Deeply embedded flow control based on intermediate results, with shared subexpressions between branches
    • Pattern matching on intermediate results, particularly in the case of extracting part of a result, using that for further computation, then reconstructing a modified version as the next result

    Writing such a function as a single expression generally requires either multiple nested lambdas, or the kind of absurd obfuscating nonsense that gives point-free style a bad name. A do block, on the other hand, provides syntactic sugar for easy nested scoping of intermediate results with embedded control flow.

    Normally you’d probably extract such subexpressions and put them in a where clause or something, but since ordinary values form a monad with function application as (>>=)–namely the Identity monad–you could conceivably write such a function in a do block instead, though people might look at you funny.


    Besides the scoping/binding stuff, the other thing a do block does for you is elide the operator that chains subexpressions together. It’s not too hard to imagine other cases where it would be nice to have a notation for “combine these expressions using this function within this block”, and then let the compiler fill in the blanks.

    In the easy case, where the expressions all have the same type, putting them in a list and then folding it works well–building strings in this manner using unwords and unlines, for instance. The benefit of do is that it combines expressions with common structure and compatible–but not identical–types.

    In fact, the same general principle is true of the “idiom bracket” notation from the Applicative paper: Where do blocks use newlines to elide monadic construction, idiom brackets use juxtaposition to elide lifted function application. The proc notation for Arrow is also similar, and other concepts could be cleanly expressed in such fashion as well, such as:

    • Composing data structures, e.g. merging result sets of some sort, eliding the merge function
    • Other function application idioms, such as argument-first “forward pipe” style, eliding the application operator
    • Parallel computations, eliding the result aggregation function

    Although it’s not too hard to make many of these into either a single type or a full Monad instance, it might be nice to have a unified, extensible bit of syntactic sugar for the general concept. There’s certainly a common thread tying together all these and more, but that’s a much larger topic not really related to syntax…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.