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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:24:32+00:00 2026-05-31T15:24:32+00:00

Small part of a code to highlight the problem: open System.IO let do_smth i

  • 0

Small part of a code to highlight the problem:

open System.IO

let do_smth i (stm : #System.IO.Stream) =  // val do_smth : 'a -> #Stream -> unit
    (*....*)
    ()

type SomeOps = SomeOps with
    static member op (i : int) = do_smth i

let test_currying i = do_smth i            // val test_currying : 'a -> (Stream -> unit)
                                           // NB: Stream, not #Stream
let main() = 
    use stm = new System.IO.MemoryStream()
    test_currying 42 stm  // OK, upcasted to Stream somehow
    SomeOps.op 42 stm     // compiler error!

Can someone explain, why is compiler’s behavior so different in last two lines? And why we lost information (about flexible #Stream) in test_currying function?

  • 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-31T15:24:34+00:00Added an answer on May 31, 2026 at 3:24 pm

    This looks like a bug to me. The compiler handles differently functions constructed using let and functions written as static member.

    In particular, I think that it does not insert flexible types for member arguments that are not explicitly declared in the member declaration (that is, arguments that are either the result of partial function application or are created using the fun construct).

    The simplest example that demonstrates the behavior does not use flexible type and looks like this:

    type A = 
      static member op = fun (s:obj) -> ()
    module B =
      let op = fun (s:obj) -> ()
    
    A.op "A" // Error 
    B.op "A" // Ok
    

    According to the specification (Section 14.4.2, posted by Brian in a deleted (?) answer), a flexible type that allows using supertypes should be inserted regardless of whether the invoked function is member or a let-bound value.

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

Sidebar

Related Questions

I need to implement a small part of my application logic in native code.
I have written some code in which a small part of the code takes
I am developing a small part of a PHP application with some python code.
I have a small code as part of a huge file as follows: if(($lastLogTime
I have a requirement to change a very small part of the WPF ComboBox's
I have an application that I have to run as Administrator. One small part
I have a small lightweight application that is used as part of a larger
I made small program to divide large pictures and take part of them. When
I work on a small Agile development team which is part of a large,
I am developing a small excel plugin. As part of it I need to

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.