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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:05:06+00:00 2026-06-07T02:05:06+00:00

In F# interactive, I can find the type of sprintf. >sprintf;; val it :

  • 0

In F# interactive, I can find the type of sprintf.

>sprintf;;
val it : (Printf.StringFormat<'a> -> 'a) = <fun:clo@163>

I can find the type of sprintf curried with the first parameter, if the curried function is not generic.

> sprintf "%g";;
val it : (float -> string) = <fun:it@134-16>

But if it is generic, then I get the value restriction error.

> sprintf "%A";;
error FS0030: Value restriction. The value 'it' has been inferred to have generic type
val it : ('_a -> string)    
Either make the arguments to 'it' explicit or, if you do not intend for it to be generic, add a type annotation.

I can add a type annotation to get rid of the value restriction like this, specializing the function for a type, eg. DateTime.

>let f : (DateTime -> string) = sprintf "%A";;
val f : (DateTime -> string)

How can I add the type annotation without the binding? I’ve tried the following …

>sprintf "%A" : (DateTime -> string);;
error FS0010: Unexpected symbol ':' in interaction. Expected incomplete structured construct at or before this point, ';', ';;' or other token.

This is a similar example but harder …

>sprintf "%a";;
error FS0030: Value restriction. The value 'it' has been inferred to have generic type
val it : ((unit -> '_a -> string) -> '_a -> string)    
Either make the arguments to 'it' 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-07T02:05:08+00:00Added an answer on June 7, 2026 at 2:05 am

    You just need to enclose your expression in parenthesis:

    open System;;
    (sprintf "%A" : DateTime -> string);;
    
    val it : (DateTime -> string) = <fun:it@2>
    

    That way you can specify the type annotation without the binding.

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

Sidebar

Related Questions

How can I make an interactive function that interactively read a key from the
In the Erlang interactive shell you can bind variables to values. If I would
I can import MySQLdb from the interactive python command line but Zope gives me
how can i save a file as iwb(interactive whiteboard ) file format in cocoa.
I need an interactive environment where i can call d functions on the fly
I have an interactive web application powered by jQuery where users can manipulate visual
I want make interactive application where user launches it and can do various task
I am trying to create an interactive map where users can click on different
In shells like the interactive python shell, you can usually use the arrow keys
I'm using pymongo and I can't figure out how to execute the mongodb interactive

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.