11namespace FSharpPlusCSharp
22open System.Runtime .CompilerServices
3+ open System.Runtime .InteropServices
34open System
45open System.Collections .Generic
56open FSharpPlus
67open FSharpPlus.Internals
7- module internal Internals =
8- module Result =
9- /// Wraps a function, encapsulates any exception thrown within to a Result
10- let inline protect f x =
11- try
12- Ok ( f x)
13- with e -> Error e
14- /// Attempts to cast an object.
15- /// Stores the cast value in Ok if successful, otherwise stores the exception in Error
16- let inline cast ( o : obj ) = protect unbox o
8+ open System.Globalization
179
10+ module internal Internals =
1811 let inline tupleToOption x = match x with true , value -> Some value | _ -> None
19-
2012open Internals
21- open System.Globalization
2213
2314[<Extension>]
2415type Options =
@@ -134,7 +125,7 @@ type Options =
134125 /// and then applies a mapping function
135126 [<Extension>]
136127 static member SelectMany ( o , f : Func < _ , _ >, mapper : Func < _ , _ , _ >) =
137- let mapper = liftA2 ( curry mapper.Invoke)
128+ let mapper = lift2 ( curry mapper.Invoke)
138129 let v = Option.bind f.Invoke o
139130 mapper o v
140131
@@ -210,7 +201,7 @@ type Results =
210201
211202 /// Attempts to cast an object.
212203 /// Stores the cast value in Ok if successful, otherwise stores the exception in Error
213- static member Cast ( o : obj ) = Result.cast o
204+ static member Cast ( o : obj ) = Result.protect unbox o
214205
215206 [<Extension>]
216207 static member ToOption c = match c with | Ok a -> Some a | _ -> None
@@ -233,7 +224,7 @@ type Results =
233224
234225 [<Extension>]
235226 static member SelectMany ( o , f : Func < _ , _ >, mapper : Func < _ , _ , _ >) =
236- let mapper = liftA2 ( curry mapper.Invoke)
227+ let mapper = lift2 ( curry mapper.Invoke)
237228 let v = Result.bind f.Invoke o
238229 mapper o v
239230
0 commit comments