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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:31:34+00:00 2026-06-03T12:31:34+00:00

Is there a reason why OCaml is not able to unroll intermediate parametrized types

  • 0

Is there a reason why OCaml is not able to unroll intermediate parametrized types in a signature ?

For instance:

(* foo.ml *)
type 'a internal = Foo of 'a
type t = string internal

and:

(* foo.mli *)
type t = Foo of string

Give an error.

I guess this is releated to the fact that the memory representation can be different sometimes, but I was wondering if there is any deeper reason before submitting a bug report to the OCaml bug-tracker…

  • 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-03T12:31:48+00:00Added an answer on June 3, 2026 at 12:31 pm

    This is not a memory representation question. When matching a type declaration against a type signature, or more generally when checking if a declaration t1 is less general than a declaration t2, the type-checker currently considers only those three cases:

    • t2 is an abstract type or type abbreviation
    • t1 and t2 are both sum types
    • t1 and t2 are both records

    The other cases fail with an error. In your case, t1 (the type being checked) is a type abbreviation, and t2 (the specification) is a sum type. This fail with a type error.

    See the source code: type_declarations in typing/includemod.ml.

    This is not a memory representation consideration as foo.ml would fail with this as well:

    type u = Foo of string
    type t = u
    

    Perhaps this check could be refined. You should ask on the bugtracker.

    Edit: it’s not trivial to tell how far this check should be refined. It is not correct in general to expand abbreviations on the signature side when checking signature matching, for example the following should not be accepted:

    module Test : sig
      type t = Foo
      type u = t (* to the outside, t and u would be equal *)
    end = struct
      type t = Foo (* while internally they are different *)
      type u = Foo (* sum/records are generative/nominative *)
    end
    

    The other way around (an internal equality is hidden from the outside) is correct and already possible:

    module Test : sig
      type t = Foo
      type u = Foo
    end = struct
      type t = Foo
      type u = t = Foo
    end;;
    
    fun (x : Test.t) -> (x : Test.u);;
    (* Error: This expression has type Test.t but an expression
       was expected of type Test.u *)
    

    Now, memory representation also come into account when considering abbreviation expansion, as the dynamic semantics (memory representation choices) of the type system is not preserved by such expansions:

    module Test : sig
      type r = { x : float; y : float; z : float } (* boxed float record *)
    end = struct
      type 'a t = { x : 'a; y : 'a; z : 'a } (* polymorphic record *)
      type r = float t
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any reason why images are not being displayed if I place it
Is there any reason for my jQuery effects not to be taking effect immediately?
Is there a reason why I should not be marking everything as public in
Is there a reason why CFRelease does not check for NULL? Isn't it unacceptable
Is there a reason why animations do not work in a loop? I know
Is there any real reason not to make a member function virtual in C++?
Is there a reason Impersonation does not seem to work with a UNC path
is there a reason I should do public class Foo { int Bar() {
Is there any reason not to send a parameter as a const & ,
Is there any reason to choose a 64bit debian over a 32bit debian instance

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.