f# - NullReferenceException on type initializer -
i playing f# types , datastructures in next code (i'm using monodevelop on mac , happens in interactive):
type unbalancedset<'a> = | e | t of unbalancedset<'a> * 'a * unbalancedset<'a> allow rec insert x = function | e -> t(e, x, e) | t(a, y, b) s -> if x < y t(insert x a, y, b) elif x > y t(a, y, insert x b) else s
it works great simple types ints floats , chars when comes strings or tuples gives next error:
let = insert (3, 9) e;; system.typeinitializationexception: exception thrown type initializer unbalancedset`1 ---> system.nullreferenceexception: object reference not set instance of object @ fsi_0004+unbalancedset`1[system.tuple`2[system.int32,system.int32]]..cctor () [0x00000] in <filename unknown>:0 --- end of inner exception stack trace --- @ <startupcode$fsi_0004>.$fsi_0004.main@ () [0x00000] in <filename unknown>:0 @ (wrapper managed-to-native) system.reflection.monomethod:internalinvoke (system.reflection.monomethod,object,object[],system.exception&) @ 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 error
i don't understand what's going on. expected code work since type comparable. clues?
this looks monodevelop issue -- i'm able run illustration code fine in f# interactive in vs2010:
> allow = insert (3, 9) e;; val : unbalancedset<int * int> = t (e,(3, 9),e)
unless else has run same issue , posts solution here, should seek posting monodevelop mailing list and/or asking #monodevelop channel on gimpnet irc.
http://monodevelop.com/index.php?title=help_%26_contact
f# mono monodevelop
No comments:
Post a Comment