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