I'm creating a type in F# that inherits from a C# class that exposes a method that returns Task<T>
in C#. I'm trying to work out what'd be the best way to do that in F#
Say my C# looks like this:
public class Foo {
public TextWriter Out { get { return Console.Out; } }
public virtual Task<SomeEnum> DoStuff() {
return Task.FromResult(SomeEnum.Foo);
}
}
public enum SomeEnum {
Foo,
Bar
}
My first pass of inheriting that type in F# looks like so:
type Bar() =
inherits Foo()
override this.DoStuff() =
this.Out.WriteLineAsync("hey from F#") |> ignore
System.Threading.Task.FromResult(SomeEnum.Bar)
But a) it doesn't feel like it's actually async and b) it just feels not-F#.
So how would I go about inheriting the Foo
class and implement the DoStuff
method that expects to return a Task<T>
?