BREAKING CHANGE: extend Option module for Maybe/FSharpOption interop

This commit is contained in:
Kyle Ratti 2022-12-23 12:36:02 -05:00
parent 2fd6b01f6b
commit a6bcd20a11
No known key found for this signature in database
GPG Key ID: 4D429B6287C68DD9

View File

@ -1,16 +1,11 @@
namespace FruityFoundation.FsBase
open System.Runtime.CompilerServices
open FruityFoundation.Base.Structures
[<Extension>]
type Extensions () =
[<Extension>]
static member ToMaybe (opt : 'a option) =
match opt with
module Option =
let toMaybe : 'a option -> Maybe<'a> = function
| Some x -> x |> Maybe.Create
| None -> Maybe.Empty ()
[<Extension>]
static member ToFSharpOption (opt : 'a Maybe) =
if opt.HasValue then Some opt.Value else None
let fromMaybe : Maybe<'a> -> 'a option = function
| x when x.HasValue -> Some x.Value
| _ -> None