FSharp.Core.Extended icon indicating copy to clipboard operation
FSharp.Core.Extended copied to clipboard

Suggestion for `try` functions

Open Happypig375 opened this issue 2 years ago • 4 comments

I propose we get rid of the try naming altogether and return valueoption by default. Existing throwing functions should have a prefix like unsafe instead: tryHead -> head, head -> tryHead >> Option.getOrThrow

Happypig375 avatar Nov 10 '23 12:11 Happypig375

I propose we get rid of the try naming altogether and return valueoption by default. Existing throwing functions should have a prefix like unsafe instead: tryHead -> head, head -> unsafeHead.

I want this library to be a drop-in replacement, meaning I intend to leave try functions in place.

We can change behaviour of normal ones too

vzarytovskii avatar Nov 10 '23 17:11 vzarytovskii

We can still include the try prefix functions for back compat then. But we can add unsafe functions and have the unprefixed functions default to try instead.

Happypig375 avatar Nov 11 '23 06:11 Happypig375

We can still include the try prefix functions for back compat then. But we can add unsafe functions and have the unprefixed functions default to try instead.

Yeah, need to emit proper messages/obsolete/compiler warnings and have a doc, since won't be a drop-in replacement anymore (for non-try variant).

vzarytovskii avatar Nov 11 '23 13:11 vzarytovskii

Also - rename Option.get to Option.getOrThrow

Happypig375 avatar May 14 '25 14:05 Happypig375