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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:34:32+00:00 2026-06-11T02:34:32+00:00

F# computation expressions have the syntax: ident { cexpr } Where ident is the

  • 0

F# computation expressions have the syntax:

ident { cexpr }

Where ident is the builder object (this syntax is taken from Don Syme’s 2007 blog entry).

In all the examples I’ve seen, builder objects are singleton instances, and stateless to boot. Don gives the example of defining a builder object called attempt:

let attempt = new AttemptBuilder()

My question: Why doesn’t F# just use the AttemptBuilder class directly in computation expressions? Surely the notation could be de-sugared to static method calls just as easily as instance method calls.

Using an instance value means that one could in theory instantiate multiple builder objects of the same class, presumably parameterised in some way, or even (heaven forbid) with mutable internal state. But I can’t imagine how that would ever be useful.


Update: The syntax I quoted above suggests the builder must appear as a single identifier, which is misleading and probably reflects an earlier version of the language. The most recent F# 2.0 Language Specification defines the syntax as:

expr { comp-or-range-expr }

which makes it clear that any expression (that evaluates to a builder object) can be used as the first element of the construct.

  • 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-06-11T02:34:33+00:00Added an answer on June 11, 2026 at 2:34 am

    Your assumption is correct; a builder instance can be parameterized, and parameters can be subsequently used throughout the computation.

    I use this pattern for building a tree of mathematical proof to a certain computation. Each conclusion is a triple of a problem name, a computation result, and a N-tree of underlying conclusions (lemmas).

    Let me provide with a small example, removing a proof tree, but retaining a problem name. Let’s call it annotation as it seems more suitable.

    type AnnotationBuilder(name: string) =
        // Just ignore an original annotation upon binding
        member this.Bind<'T> (x, f) = x |> snd |> f
        member this.Return(a) = name, a
    
    let annotated name = new AnnotationBuilder(name)
    
    // Use
    let ultimateAnswer = annotated "Ultimate Question of Life, the Universe, and Everything" {
        return 42
    }
    let result = annotated "My Favorite number" {
        // a long computation goes here
        // and you don't need to carry the annotation throughout the entire computation
        let! x = ultimateAnswer
        return x*10
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been toying with monads in F# (aka computation expressions) and I wrote this
I have a series of F# data structures which I cannot control (computation expressions
F# Computation Expressions allow to hide the complexity of monadic syntax behind a thick
I have algorithm/computation in Java and unit test for it. The unit test expects
I'm trying to optimize an (infinite) computation algorithm. I have an infinte Sum to
I don't have formal knowledge of continuations, and am wondering if someone can help
I have this function (produces the fibonacci sequence): unfoldr (\(p1, p2) -> Just (p1+p2,
I am have completed javascript validation of a form using Regular Expressions and am
This is the Pseudocode I have written for a JAVA application to calculate distance
Quick question asking for insight from this community: Which one is preferable? Option ①

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.