From a6bcd20a1155448de3175b429ca8c177242cab6c Mon Sep 17 00:00:00 2001 From: Kyle Ratti Date: Fri, 23 Dec 2022 12:36:02 -0500 Subject: [PATCH] BREAKING CHANGE: extend Option module for Maybe/FSharpOption interop --- FsBase/Extensions.fs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/FsBase/Extensions.fs b/FsBase/Extensions.fs index b0a97f3..5d66624 100644 --- a/FsBase/Extensions.fs +++ b/FsBase/Extensions.fs @@ -1,16 +1,11 @@ namespace FruityFoundation.FsBase - -open System.Runtime.CompilerServices open FruityFoundation.Base.Structures -[] -type Extensions () = - [] - 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 () - [] - static member ToFSharpOption (opt : 'a Maybe) = - if opt.HasValue then Some opt.Value else None \ No newline at end of file + let fromMaybe : Maybe<'a> -> 'a option = function + | x when x.HasValue -> Some x.Value + | _ -> None