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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:29:54+00:00 2026-05-27T17:29:54+00:00

I have a module StringMap built by the functor Map.Make given a type String

  • 0

I have a module StringMap built by the functor Map.Make given a type String:

module StringMap = Map.Make(String)

Besides the ordinary operations provided by Map, I would like to add more definitions in this module, for instance, my_own_function, such that I could call StringMap.my_own_function. Does anyone know where I should define this kind of functions and their signature?

  • 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-27T17:29:55+00:00Added an answer on May 27, 2026 at 5:29 pm

    You can use the include keyword inside a new module to add all the same functions. This was also extended to the signature in OCaml 3.12.

    module StringMap =
        struct
            include Map.Make(String)
        end
    

    If you want to access the structure of the map, you’ll have to add some Obj.magic or the %identity special external function. The redefinition of the type must be exact since no type checking is happening,

    module Make (Ord : Map.OrderedType) =
        struct
            include Map.Make(Ord)
    
            type 'a impl = Empty 
                         | Node of 'a impl * key * 'a * 'a impl * int
    
            external impl_of_t : 'a t -> 'a impl = "%identity"
            external t_of_impl : 'a impl -> 'a t = "%identity"
    
            let cardinal map =
                let rec cardinal = function
                    | Empty -> 0
                    | Node(l,_,_,r,_) -> cardinal l + 1 + cardinal r
                in
                cardinal (impl_of_t map)
    
        end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a module that uses std::string as part of its interface. I would
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I have a module in the parent directory of my script and I would
I have a module in Fortran called QFoo. It defines a type QFooType. I
I am not very familiar with Map module in Ocaml. I have a simple
I have a module that conflicts with a built-in module. For example, a myapp.email
I have a module job_post which installs job_post content type. In this module I
I have module application. When I run it, the main window of that app
I have a module that sends an email to a specified email address but
i have a module (a single .py file, actually), with a class called HashedDir.

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.