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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:24:14+00:00 2026-06-11T14:24:14+00:00

There is a common problem that F# does not natively support infix-style use of

  • 0

There is a common problem that F# does not natively support infix-style use of functions that is available in Haskell:

isInfixOf :: Eq a => [a] -> [a] -> Bool
isInfixOf "bar" "foobarbaz"
"bar" `isInfixOf` "foobarbaz"

The best known solution for F# can be found here:

let isInfixOf (what:string) (where:string) =
    where.IndexOf(what, StringComparison.OrdinalIgnoreCase) >= 0
let found = "bar" |>isInfixOf<| "foobarbaz"

Also, it is easy to improve it a bit, employing native operators precedence:

let ($) = (|>)
let (&) = (<|)
let found = "bar" $isInfixOf& "foobarbaz"

There’s also XML-ish </style/>, described here.

I would like to find a better solution, with the following criteria:

  • Single character operator (or a pair) that does not destroy commonly used operators;
  • It should be the same character, likewise grave accent (back quote) character serves in Haskell;
  • It should not destroy associativity (support chaining):

    let found = "barZZZ" |>truncateAt<| 3 |>isInfixOf<| "foobarbaz"
    
  • Optionally, it should support functions taking tuples:

    let isInfixOf (what:string, where:string) = ...
    // it will not work with |> and <|
    
  • Optionally, it should gracefully handle functions/3:

    val f: 'a -> 'b -> 'c -> 'd = ...
    let curried = a |>f<| b c
    // this wouldn't compile as the compiler would attempt to apply b(c) first
    

P.S. Various coding tricks are also welcome as I believe the good one (when checked by the F# Dev team) can be a part of the language in the future.

  • 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-11T14:24:15+00:00Added an answer on June 11, 2026 at 2:24 pm

    I agree that the ability to turn functions into infix operators in Haskell is neat in some situations. However, I’m not sure if this feature would fit well with the usual F# programming style, because the same can be achieved using members.

    For example, let’s take your snippet that uses truncateAt and isInfixOf:

    let found = "barZZZ" |>truncateAt<| 3 |>isInfixOf<| "foobarbaz" 
    

    If we define TruncateAt and IsInfixOf as extension methods of string, then you can write:

    let found = "barrZZZ".TruncateAt(3).IsInfixOf("foobarbaz") 
    

    This version is shorter and I personally think it is also more readable (espcially to someone with .NET programming background as opposed to Haskell background). You also get IntelliSense when you hit ., which is a nice bonus. Of course, you have to define these operations as extension methods, so you need to more carefuly consider the design of your libraries.

    For completeness, the extension methods are defined as follows:

    type System.String with
      member what.IsInfixOf(where:string) = 
        where.IndexOf(what, StringComparison.OrdinalIgnoreCase) >= 0 
      member x.TruncateAt(n) = 
        x.Substring(0, n)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a standard/common way to give compiler-style error messages that point to a
Does anyone know if there is a common javascript library to enable scrolling that
It appears after much searching that there seems to be a common problem when
Is there a common standard for reporting errors in your class functions? I've seen
Is there a common interface in Python that I could derive from to modify
I know jquery/ajax in IE is a common problem. There is a lot of
This seems like an obvious question but there does not appear to be an
I imagine this is common enough that it's a solved problem, but being a
This is a common problem, and there many common answers for this, but I
Is there a common method/api to list all web browsers (name, executable, default yes/no)

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.