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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:52:50+00:00 2026-05-22T16:52:50+00:00

I defined a custom equality operator (the definition is not really important so I

  • 0

I defined a custom equality operator (the definition is not really important so I will insert dummy stuff):

let ( ~=~ ) a b = true

If I try to use it infix:

if a ~=~ b then 1 else 2

I get the following error:This expression is not a function; it cannot be applied.

I can fix this either by renaming the operator from ~=~ to =~ or by calling it as a function: if (~=~) a b then 1 else 2.

This seems that is a general problem with operators that start with ~.
My question is why I can’t use such operators infix? Is anything special about ~ symbol?

Note: I already went through documentation but I couldn’t find anything relevant. Maybe I missed something?

  • 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-22T16:52:51+00:00Added an answer on May 22, 2026 at 4:52 pm

    In OCaml, whether an operator is infix or prefix is determined by its first character.
    In you case, the character ‘~’ is for prefix: by let (~=~) a b = …, you are defining a prefix operator. ~=~ a is a valid expression, and returns a function.

    In addition to infix or prefix, infix operator associativity (left or right) and operator precedences (which of + and * has stronger?) are syntactically determined by the first character of the operator.

    This sounds ugly, since you cannot have control of your fancy operators characteristics, but it makes easier to read OCaml source code by someone else with lots of strange custom operators.

    Here is the table of chars for operators:

    The first char   :  prefix/infix/connectivity power/left-or-right
    ! ~ ?            :  prefix
    = < > | & $      :  infix0, left
    @ ^              :  infix1, right
    + -              :  infix2, left
    * /              :  infix3, left  ( ** is exceptional. It is right assoc and have power 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say in a custom control I defined some custom event myEvent. Now when
How can I define a custom operator - for example equality operator - for
I have a custom class for which I've defined a custom cast operator char()
Documentation states: Adds a user-defined custom member to an instance of a Windows PowerShell
I have defined a custom Sharepoint list for special attributes related to a software
I have defined a custom list template type for SharePoint . I install it
I have defined a custom IPrincipal and custom IIdentity based on a website that
I've defined a custom content type - news. I also have a menu item
I have defined a custom file type with these lines: syn region SubSubtitle start=+=+
Is it possible to have scoped macros using custom defined macros through boost wave?

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.