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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:37:35+00:00 2026-06-08T13:37:35+00:00

I am puzzled as to why the 3rd function would not work : let

  • 0

I am puzzled as to why the 3rd function would not work :

   let generate1 = id
   let generate2 = let a = 1
                   id
   let generate3 = printfn "hi"
                   id

while the first 2 are fine, the last one spits out

error FS0030: Value restriction. The value 'generate3' has been inferred to have generic type
    val generate3 : ('_a -> '_a)    
Either make the arguments to 'generate3' explicit or, if you do not intend for it to be generic, add a type annotation.
  • 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-08T13:37:36+00:00Added an answer on June 8, 2026 at 1:37 pm

    I won’t attempt to explain value restriction, but I will attempt to sort out the semantic differences between these three values.

    generate1 is just an alias for id, so we’re good there.

    generate3 does some computations before returning id, hitting value restriction.

    Then why doesn’t generate2 hit value restriction like generate3? Because the compiler can see that let x = 1 in id is semantically equivalent to just id: 1 is a constant expression and x not used in the body of the let ... in ... expression, so the compiler can and does throw them away. On-the-other-hand, if you replace 1 with a potential side-effect like sin 2.3 (sin is pure, but the compiler can’t prove it), then the compiler can’t safely reduce the expression, thus hitting value restriction as with generate3.

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

Sidebar

Related Questions

Im puzzled let test = aString let callMe = printfn test Why isn't this
I'm a bit puzzled: From Cocoa Programming For Mac OS X (page 63, 3rd
I am puzzled why this return false doesn't cancel the post-back. function validate() {
I'm puzzled about the execution order of the following: $('#home').live('pageinit',function(){ $('#test').hide(); $(function() { alert('test1');
I'm puzzled with a strange mouse listener behavior. First, I defined an interface :
I'm puzzled... I have this function colorWithHexString... when I include it in the viewcontroller
I'm puzzled by this notation that did spread a lot after the first templating
I am a little puzzled why the following is not working, button_ONE does a
I am puzzled with the statement that IE does not support <q> tag but
I was puzzled when this query failed on me: $results = $this->Event->find('first', array('conditions'=>array( 'user_id'

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.