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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:32:36+00:00 2026-05-31T23:32:36+00:00

What is the conventional way to create an interface in OCaml? It’s possible to

  • 0

What is the conventional way to create an interface in OCaml? It’s possible to have an interface with a single implementation by creating an interface file foo.mli and an implementation file foo.ml, but how can you create multiple implementations for the same interface?

  • 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-31T23:32:37+00:00Added an answer on May 31, 2026 at 11:32 pm

    If you’re going to have multiple implementations for the same signature, define your signature inside a compilation unit, rather than as a compilation unit, and (if needed) similarly for the modules. There’s an example of that in the standard library: the OrderedType signature, that describes modules with a type and a comparison function on that type:

    module type OrderedType = sig
      type t
      val compare : t -> t -> int
    end
    

    This signature is defined in both set.mli and map.mli (you can refer to it as either Set.OrderedType or Map.OrderedType, or even write it out yourself: signatures are structural). There are several compilation units in the standard library that have this signature (String, Nativeint, etc.). You can also define your own module, and you don’t need to do anything special when defining the module: as long as it has a type called t and a value called compare of type t -> t -> int, the module has that signature. There’s a slightly elaborate example of that in the standard library: the Set.Make functor builds a module which has the signature OrderedType, so you can build sets of sets that way.

    (* All four modules passed as arguments to Set.Make have the signature Set.OrderedType *)
    module IntSet = Set.Make(module type t = int val compare = Pervasives.compare end)
    module StringSet = Set.Make(String)
    module StringSetSet = Set.Make(StringSet)
    module IntSetSet = Set.Make(IntSet)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create something like a MDI tabbed Interface so I have a
Is there any way to create a naming convention for my primary key constraints
Or would a conventional client-server VCS be more appropriate? I'm currently using TortoiseSVN, but
In the Fibonacci sequence, I have seen conventional implementations which recursively call the same
I want to define a protocol and create an easy, standard way to grab
I'm using a UISearchViewController in a slightly non-conventional way. My UISearchBar is initially hidden.
I have an interface ( IRepository<T> ) that is currently being extended for each
I try to dynamically create an XML schema (XSD) from C#, using the conventional
I'm reading in an XML file from an XMLReader class, which I create and
Is there any way within an RSpec tests, by convention or code, to have

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.