There is a convenient undefined value in Haskell that can be used as a stub for yet to be defined functions/paths in code. Is there anything like it in F#?
To be concrete, you can define such a value like this:
let undefined<'T> : 'T = failwith "Not implemented yet"
let stub1 (x : int) : float = undefined
let stub2 (x : 'T) : 'T = undefined
Beware that F# evaluation is strict. If you bind undefined
to a top-level value, it will throw an exception during evaluation.
I think
failwith "Not implemented"
would be pretty much equivalent
More specific and .NET-friendly way
let undefined<'T> : 'T = raise (NotImplementedException())
allows you to skip typing a message and still differentiate this exception from other ones in a catch block or stack trace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With