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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:06:31+00:00 2026-05-14T00:06:31+00:00

After messing about with F# there are some really nice features that I think

  • 0

After messing about with F# there are some really nice features that I think I am going to miss when I HAVE to go back to C#, any clues on how I can ween myself off the following, or better still duplicate their functionality:

  • Pattern Matching (esp. with Discriminating Unions)
  • Discriminating Unions
  • Recursive Functions (Heads and Tails on Lists)

And last but not least the Erlang inspired Message Processing.

  • 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-14T00:06:31+00:00Added an answer on May 14, 2026 at 12:06 am

    I’m not sure to what extent is this really a question. However, here are some typical patterns that I use to encode these functional constructs in C# (some of them come from my book, which has a source code available).

    Discriminated unions – there is really no good way to implement discriminated unions in C# – the only thing you can do is to implement them as a class hierarchy (with a base class representing the DU type and a derived class for each of the DU case). You can also add Tag property(of some enum type) to the base class to make it easer to check which case the class represents. As far as I know, this is used in LINQ expression trees (which really should be discriminated union).

    Pattern matching – you’ll probably never get this in a fully general way (e.g. with nested patterns), but you can simulate pattern matching on discriminated unions like this (using the Option<int> type which is either Some of int or None):

    Option<int> value = GetOption();
    int val;
    if (value.TryMatchSome(out val)) 
      Console.WriteLine("Some {0}", val);
    else if (value.TryMatchNone()) 
      Console.WriteLine("None");
    

    Not perfect, but at least you get a relatively nice way to extract values from the cases.

    Message passing – there is Concurrency and Coordination Runtime, which is in some ways also based on message passing and can be used in C#. I bet you could also use F# mailbox processor from C# using a technique based on iterators, which I described in this article and is also used in Wintellect PowerThreading library. However, I don’t think anybody implemented a solid message passing library based on this idea.

    In summary, you can simulate many functional features in C#, at least to some extend and use some other without any problems (lambda functions and higher-order functions). However, if you need the full power of F#, then you just need to convince your company to start using F# :-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Messing about a bit, i have a working Adobe After Effects plugin with a
I have to find recursively if there is any repeated element in an integer
After googling and binging for a whole day about this, and even trying some
I could really use some help optimizing a table on my website that is
I think it is by design and there is nothing can be done about
Given a base class where I have some logic that must run before and
I have some Razor code that has conditional logic based on whether a certain
After the suggestion to use a library for my ajax needs I am going
After being told by at least 10 people on SO that version control was
After lots of attempts and search I have never found a satisfactory way to

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.