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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:22:17+00:00 2026-05-30T19:22:17+00:00

Looking at: member this.PostAndReply : (AsyncReplyChannel<‘Reply> -> ‘Msg) * ?int -> ‘Reply I can’t

  • 0

Looking at:

member this.PostAndReply : (AsyncReplyChannel<'Reply> -> 'Msg) * ?int -> 'Reply

I can’t figure out why the signature looks so counter-intuitive to me. What we want to do is posting a message to an agent, and wait for a reply.
Why do we have to give him a weird function as a ‘message’?

See again this MSDN snippet:

let rec loop() =
    printf "> "
    let input = Console.ReadLine()
    printThreadId("Console loop")
    let reply = agent.PostAndReply(fun replyChannel -> input, replyChannel)
    if (reply <> "Stopping.") then
        printfn "Reply: %s" reply
       loop()
    else
        ()
loop()

I’d rather prefer something like this:

member this.PostAndReply : 'Msg * ?int -> 'Reply

Thanks

  • 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-30T19:22:18+00:00Added an answer on May 30, 2026 at 7:22 pm

    This type signature looks pretty confusing when you see it for the first time, but it does make sense.

    The F# library design
    The idea behind the is that when you call PostAndReply you need to give it a function that:

    • constructs a message of type 'Msg (to be sent to the agent)
    • after the F# runtime builds a channel for sending messages back to the caller (channels are represented as values of type AsyncReplyChannel<'Reply>).

    The message that you construct needs to contain the reply channel, but the F# library does not know how you want to represent your messages (and so it does not know how you want to store the reply channel in the message). As a result, the library asks you to write a function that will construct the message for the agent after the system constructs the channel.

    Your alternative suggestion
    The problem with your suggestion is that if PostAndReply had a type 'Msg -> 'Reply, the message that the agent receives after it calls Receive would be of the following type:

    'Msg * AsyncReplyChannel<'Reply>
    

    … so every message received to the agent would also have to carry a channel for sending replies back. However, you probably don’t want to send a reply back for every received message, so this wouldn’t really work. Maybe you could use something like:

    'Msg * option<AsyncReplyChannel<'Reply>>
    

    … but that’s just getting more complicated (and it still isn’t quite right, because you can only reply to some messages from 'Msg, but not to all of them).

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

Sidebar

Related Questions

I'm looking at a member function int funct(int x) const; And I'm wondering if
Possible Duplicate: What is this weird colon-member syntax in the constructor? I am looking
I have a model looking like this. class ProjectMembership(models.Model): member = models.ForeignKey(User, related_name='project_membership_member_set') Edit:
I'm baffled that I can't find a quick answer to this. I'm essentially looking
Looking at what's running and nothing jumps out. Thanks!
When looking over the member functions of the STL containers, an odd thought occurred
Looking at the interface System.Collections.Generic.ICollection its definition requires that the inheriting member contains the
I've got an array like this array 2 => string 'Member forum 1' 5
This is a use case in member enrollment via web application/web service. We have
I was looking at some old webpages constructed by a previous member of staff

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.