For a memberless interface
type IFoo = interface end
it is possible to create an instance using an object expression
let foo = { new IFoo }
However, it is not possible to do the same with an abstract class that does not have abstract elements.
[<AbstractClass>] type Foo() = class end let foo = { new Foo() }
gives an error: Invalid object expression. Objects without overrides or interfaces should use the form expression 'new Type (args)' without curly braces. Well, we know that won't work either.
Here's a hacky workaround
let foo = { new Foo() with member __.ToString() = base.ToString() }
Is there a better way to create an object expression for an abstract type without abstract elements?
source share