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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:08:30+00:00 2026-05-19T02:08:30+00:00

In F# what is the type annotation for a typed list (e..g list of

  • 0

In F# what is the type annotation for a typed list (e..g list of int)? With a simple function I can do annotations as follows:

let square(x:int) = …

I’ve annotated x as an int type. But what if I want to do a type annotation for an int list? For example, let’s say I have a max function that expects a list – how would I do a type annotation for it?

let max(numbers:??) = …

  • 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-19T02:08:31+00:00Added an answer on May 19, 2026 at 2:08 am

    There are two options:

    let max (numbers:int list) = ... 
    let max (numbers:list<int>) = ... 
    

    The first version uses syntax that is inherited from OCaml (and is frequently used for primitive F# types such as lists). The second version uses .NET syntax (and is more frequently used for .NET types or when writing object-oriented code in F#). However, both of them mean exactly the same thing.

    In any case, the form of type annotation is always (<something> : <type>) where <something> is either a pattern (as in parameter list) or an expression. This means that int list and list<int> are just names of types. F# Interactive prints the type if you enter some value, so you can use this to learn more about how type names are written:

    > [1;2;3]
    val it : int list = [ 1; 2; 3 ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add an attribute using javax.xml.bind.annotation to a simple type (String
Type.GetFields() does not return fields in a particular order, but I want to sort
I have a F# function: let removeEven (listToGoUnder : _ list) = let rec
Let's say I have a list and a set and I want to do
When and where do you put type annotations in Clojure code? Obviously when performance
EBay's VJET and Google's Closure Compiler both use type annotations in Javascript comments. Why
I read about using <context:component-scan base-package=tld.mydomain.business> <context:include-filter type=annotation expression=org.springframework.stereotype.Service/> </context:component-scan> and annotate my service
type(3,) returns the int type, while t = 3, type(t) returns the tuple type.
The type of this function is T -> (T -> U) -> U .
I'm trying to make a function array, which I'm using inside a List.reduce HOF.

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.