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

  • Home
  • SEARCH
  • 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 7804649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:59:02+00:00 2026-06-02T01:59:02+00:00

Given the following fragment: type Foo() = static member Test (act : unit ->

  • 0

Given the following fragment:

type Foo() =
    static member Test (act : unit -> unit) = act()
    static member Test (act : Action) = Foo.Test act.Invoke

I get an error on the final line stating: A unique overload for method ‘Test’ could not be determined based on type information prior to this program point. A type annotation may be needed.

Unfortunately, the type annotation (act.Invoke : unit -> unit) does not resolve the ambiguity, and I cannot find an annotation that does fix it. I would like the Action version of be a wrapper round the -> version. My particular use case is defining a class that will be called from both F# and C#, so I want it to work natively from both languages.

  • 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-02T01:59:04+00:00Added an answer on June 2, 2026 at 1:59 am

    F# inserts the conversion to Action for you, so you could (in theory) get by with one method.

    type Foo() =
        static member Test (act : Action) = act.Invoke()
    
    Foo.Test (fun () -> ())
    

    I can’t figure out how to force the compiler to choose between Action and unit -> unit. Two other options:

    1. make the Action overload the primary and do Foo.Test(Action(act))
    2. put the logic in a third function which is called from the public methods

    But my recommendation would be a single method taking Action. Since the conversion is automatic, interop, in a sense, is free.

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

Sidebar

Related Questions

Given the following HTML fragment: <span name=foo class=foo-class> <input name=foo value=0 id=foo2_0 type=radio> <label
Given the following HTML fragment: <div class=word> <input type=text name=A /> <input type=text name=n
Given the following XML fragment: <foo> <bar>1</bar> <bar>2</bar> <bar>3</bar> </foo> The following XSL should
Given the following fragment of html: <fieldset> <legend>My Legend</legend> <p>Some text</p> Text to capture
Given the following xml fragment: <Problems> <Problem> <File>file1</File> <Description>desc1</Description> </Problem> <Problem> <File>file1</File> <Description>desc2</Description> </Problem>
Given the following JSF fragment: <h:outputText ... rendered=#{bean.r} /> <h:outputText ... rendered=#{bean.r} /> <h:outputText
Given a XmlNode containing the following XML fragment, how do I fill XmlNodeList with
Given the following HTML fragment: <form id=aspnetForm onsubmit=alert('On Submit Run!'); return true;> I need
Given the following HTML-Fragment: <div> <p> abc <span id=x>[</span> def <br /> ghi </p>
Given the following HTML fragment: <p id=para>hello &lt;world&gt;</p> The jQuery .text() and .html() methods

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.