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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:31:33+00:00 2026-06-19T02:31:33+00:00

I was playing with F# types and datastructures in the following code (I’m using

  • 0

I was playing with F# types and datastructures in the following code (I’m using Monodevelop on a Mac and this only happens in the Interactive):

type UnbalancedSet<'a> =
    | E
    | T of UnbalancedSet<'a> * 'a * UnbalancedSet<'a>

let rec insert x = function
    | E -> T(E, x, E)
    | T(a, y, b) as s -> 
        if x < y then T(insert x a, y, b)
        elif x > y then T(a, y, insert x b)
        else s

It works great with simple types as ints floats and chars but when it comes to strings or tuples it gives the following error:

let a = insert (3, 9) E;;

System.TypeInitializationException: An exception was thrown by the type initializer for UnbalancedSet`1 ---> System.NullReferenceException: Object reference not set to an instance of an object
  at FSI_0004+UnbalancedSet`1[System.Tuple`2[System.Int32,System.Int32]]..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at <StartupCode$FSI_0004>.$FSI_0004.main@ () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Stopped due to error

I don’t understand what’s going on. I expected this code to work since the type is comparable. Any clues?

  • 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-19T02:31:34+00:00Added an answer on June 19, 2026 at 2:31 am

    This looks like a MonoDevelop issue — I’m able to run your example code just fine in F# Interactive in VS2010:

    > let a = insert (3, 9) E;;
    
    val a : UnbalancedSet<int * int> = T (E,(3, 9),E)
    

    Unless anyone else has run into this same issue and posts the solution here, you should try posting this to the MonoDevelop mailing list and/or asking the #monodevelop channel on GIMPnet IRC.

    http://monodevelop.com/index.php?title=Help_%26_Contact

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

Sidebar

Related Questions

I've been playing with Haskell data types for the past few days, using a
I have started playing around with Apache camel recently. So being the experimental type
I have created this datastructure: class Event { public: Event(EVENT_TYPE type, void* pSender =
I've been playing around trying to thoroughly understand Reference and Value types. Just when
I'm playing with TypesScript, but the compiler complains when I use browser types such
I've been playing around with ASP.NET MVC 4 beta and I see two types
I am playing with making a blog. I would like to have several types
I am playing around with a new project, a split view iPad app using
I've been playing around with Expression Trees. I have the following simple method that
This might be more of a cassini issue with MIME Types (can you change

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.