BREAKING CHANGE: extend Option module for Maybe/FSharpOption interop
This commit is contained in:
parent
2fd6b01f6b
commit
a6bcd20a11
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user