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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:48:41+00:00 2026-06-18T02:48:41+00:00

In Ocaml, tuples with different arities have different type and value constructors: # let

  • 0

In Ocaml, tuples with different arities have different type and value constructors:

# let a = (1, 2, 3);;
val a : int * int * int = (1, 2, 3)
# let b = (1, (2, 3));;
val b : int * (int * int) = (1, (2, 3))

Note that second example (b) is more flexible than first (a) because “tail” of b – (2, 3) – itself is valid value:

# let (_, c) = b;;
val c : int * int = (2, 3)
# let d = snd b;;
val d : int * int = (2, 3)

What is the reason to not parse “(1, 2, 3)” as “(1, (2, 3))” and instead introduce infinite (or, even worse, finite) amount of new type and value constructors for different arities?

  • 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-18T02:48:42+00:00Added an answer on June 18, 2026 at 2:48 am

    What is the reason to not parse “(1, 2, 3)” as “(1, (2, 3))” and instead introduce infinite (or, even worse, finite) amount of new type and value constructors for different arities?

    The ML type system was designed in the pursuit for stronger static type checking in order to catch as many errors at compile time as possible.

    Your suggestion would weaken the type system considerably because it would no longer be able to distinguish between (1, 2, 3) and (1, (2, 3)) which is a move in the opposite direction.

    In practice, I can tell you that ML making such distinctions has caught real errors in my production code in the past. I value the ML design in this context.

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

Sidebar

Related Questions

In ocaml, let's say we have: type t = A of int | B
As a beginner in Ocaml, I have this current working code: ... let ch_in
For [1] : # let make pair int (x:int) (y:int) = x,y ;; val
I just learned that OCAML have to have a . postfix for doing float
I have an ocaml type : type t = A | B | ...
I have an Ocaml function that is giving me errors. What I am trying
I need an OCaml map with keys of type int so I am using
I am writing a ocaml project, in which I have a function that replace
The OCaml GC imposes a global lock that prevents mutators (threads) from running in
What OCaml libraries are out there that provide lazy list handling? I am looking

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.