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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:28:18+00:00 2026-05-25T12:28:18+00:00

I’m either not seeing something obvious or just generally confused The code I have

  • 0

I’m either not seeing something obvious or just generally confused
The code I have looks like:

let inline createContext source destination  =
    let src = (fun amount (s:^T) -> (^T : (member DecreaseBalance : decimal -> ^a) (s, amount)))
    let dst = (fun amount (d:^T) -> (^T : (member IncreaseBalance : decimal -> ^a) (d, amount)))
    let log = (fun msg a -> (^T : (member LogMessage : string -> ^a) (a, msg)))
    let f = fun amount -> src amount source |> ignore
                          log "" source |> ignore
    let f = fun amount -> dst amount destination |> ignore
                          log "" destination |> ignore
    new Context (source, destination, src, dst, log)
let src = new Account(0m)
let dst = new Account(0m)
let ctxt = createContext src dst

The type Account fullfils the member constraints of createContext. Intellisense claims the signartur of createContext to be Account -> Account -> Context but the compiler complains at src in the last line with “This expression was expected to have type unit but here has type Account”
Any idea of what I’m missing?

If I rename a member function of Account so it no longer meets the constraints I get
“The type ‘Account’ does not support any operators named ‘LogMessage'” which is what I would expect in that scenario. I get the same error message if I pass () as the first argument. That unit doesn’t support LogMessage (not that it would bring me any good if that actually compiled)

  • 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-25T12:28:20+00:00Added an answer on May 25, 2026 at 12:28 pm

    This compiles fine for me, given the following types

    type Context(a, b, c, d, e) = class end
    type Account(a) = 
      member __.DecreaseBalance(a) = Unchecked.defaultof<_>
      member __.IncreaseBalance(a) = Unchecked.defaultof<_>
      member __.LogMessage(a) = Unchecked.defaultof<_>
    

    I suspect something else is going on. Can you show more of the code?

    It’s strange that createContext is inferred to be Account -> Account -> Context. I would expect 'T -> 'T -> Context ('T requires member DecreaseBalance and IncreaseBalance and LogMessage). That may or may not be a clue to your problem.

    If possible, replace the static member constraints with an interface.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.