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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:51:42+00:00 2026-05-23T20:51:42+00:00

I have defined a function like the following: let ff (f1: a_function) (f2: a_function)

  • 0

I have defined a function like the following:

let ff (f1: a_function) (f2: a_function) (v0: type1) (v1: type2): type3 = ...

And another function like the following works:

let f: type1 -> type2 -> type3 = ff f1 f2

But another declaration like the following does not work:

let f (v0: type1) (v1: type2): type3 = ff f1 f2

The error message is:

Error: This expression has type
         type1 -> type2 -> type3
       but an expression was expected of type type3

I have always thought that let f: type1 -> type2 -> type3 is same as let f (v0: type1) (v1: type2): type3. Could anyone tell me why the first declaration works but not the second?

Thank you very much

PS1: My key question is, given let f (v0: type1) (v1: type2): type3 = ff f1 f2, isn’t the type of f type1 -> type2 -> type3?

If let f (v0: type1) (v1: type2): type3 = ff f1 f2 and let f (v0: type1) (v1: type2): type3 = ff f1 f2 returns same type of f, what is the difference between these 2 signatures?

  • 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-23T20:51:43+00:00Added an answer on May 23, 2026 at 8:51 pm

    Arguments v0, v1 of your second definition are dangling. This declaration works, on the other hand:

    module type TimurTest =
      sig
        type type1
        type type2
        type type3
        type functional1
        type functional2
        val f1 : functional1
        val f2 : functional2
        val ff : functional1 -> functional2 -> type1 -> type2 ->type3
      end
    
    module MyTest(M:TimurTest) =
      struct
        let f : M.type1 -> M.type2 -> M.type3 = M.ff M.f1 M.f2
        let f (v0: M.type1) (v1: M.type2) : M.type3 = M.ff M.f1 M.f2 v0 v1
        let g (v0: M.type1) (v1: M.type2) = M.ff M.f1 M.f2
      end
    

    The last line answers your PS (notice I haven’t specified the return type of g, to let the compiler infer what it should be): since its definition ignores arguments v0 and v1, the curried meaning of g (v0:type1) (v1:type2) = ff f1 f2 gives it the type type1 -> type2 -> type1 -> type2 -> type3. Basically, you require two additional arguments whose value you’re going to throw away (not passing them to ff f1 f2, which is going to require two of its own).

    And indeed, when declaring the above module, part of the response of the compiler is:

          val g : M.type1 -> M.type2 -> M.type1 -> M.type2 -> M.type3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple custom exception defined like like the following but I don't
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
I am getting the warning: function used but not defined . I have static
So..Let's say I have the following code snippet function Rectangle(w,h){ this.width = w; this.height
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new
I have a user defined function in SQL called getBuisnessDays it takes @startdate and
How can I hook up an event to a function name I have defined
I have a Delphi DLL with a function defined as: function SubmitJobStringList(joblist: tStringList; var
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a
I have a function in a native DLL defined as follows: #include <string> void

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.