@@ -7,21 +7,21 @@ open System
7
7
module AsyncOptionCE =
8
8
type AsyncOptionBuilder () =
9
9
10
- member __.Return ( value : 'T ) : Async < Option < _ > > =
10
+ member __.Return ( value : 'T ) : Async < _ option > =
11
11
async.Return <| option.Return value
12
12
13
13
member __.ReturnFrom
14
- ( asyncResult : Async < Option < _ > >)
15
- : Async < Option < _ > > =
14
+ ( asyncResult : Async < _ option >)
15
+ : Async < _ option > =
16
16
asyncResult
17
17
18
- member __.Zero () : Async < Option < _ > > =
18
+ member __.Zero () : Async < _ option > =
19
19
async.Return <| option.Zero ()
20
20
21
21
member inline __.Bind
22
- ( asyncResult : Async < Option < _ > >,
23
- binder : 'T -> Async < Option < _ > >)
24
- : Async < Option < _ > > =
22
+ ( asyncResult : Async < _ option >,
23
+ binder : 'T -> Async < _ option >)
24
+ : Async < _ option > =
25
25
async {
26
26
let! result = asyncResult
27
27
match result with
@@ -30,46 +30,46 @@ module AsyncOptionCE =
30
30
}
31
31
32
32
member __.Delay
33
- ( generator : unit -> Async < Option < _ > >)
34
- : Async < Option < _ > > =
33
+ ( generator : unit -> Async < _ option >)
34
+ : Async < _ option > =
35
35
async.Delay generator
36
36
37
37
member this.Combine
38
- ( computation1 : Async < Option < _ > >,
39
- computation2 : Async < Option < _ > >)
40
- : Async < Option < _ > > =
38
+ ( computation1 : Async < _ option >,
39
+ computation2 : Async < _ option >)
40
+ : Async < _ option > =
41
41
this.Bind( computation1, fun () -> computation2)
42
42
43
43
member __.TryWith
44
- ( computation : Async < Option < _ > >,
45
- handler : System.Exception -> Async < Option < _ > >)
46
- : Async < Option < _ > > =
44
+ ( computation : Async < _ option >,
45
+ handler : System.Exception -> Async < _ option >)
46
+ : Async < _ option > =
47
47
async.TryWith( computation, handler)
48
48
49
49
member __.TryFinally
50
- ( computation : Async < Option < _ > >,
50
+ ( computation : Async < _ option >,
51
51
compensation : unit -> unit )
52
- : Async < Option < _ > > =
52
+ : Async < _ option > =
53
53
async.TryFinally( computation, compensation)
54
54
55
55
member __.Using
56
56
( resource : 'T when 'T :> IDisposable ,
57
- binder : 'T -> Async < Option < _ > >)
58
- : Async < Option < _ > > =
57
+ binder : 'T -> Async < _ option >)
58
+ : Async < _ option > =
59
59
__. TryFinally (
60
60
( binder resource),
61
61
( fun () -> if not <| obj.ReferenceEquals( resource, null ) then resource.Dispose ())
62
62
)
63
63
64
64
member this.While
65
- ( guard : unit -> bool , computation : Async < Option < _ > >)
66
- : Async < Option < _ > > =
65
+ ( guard : unit -> bool , computation : Async < _ option >)
66
+ : Async < _ option > =
67
67
if not <| guard () then this.Zero ()
68
68
else this.Bind( computation, fun () -> this.While ( guard, computation))
69
69
70
70
member this.For
71
- ( sequence : #seq<'T> , binder : 'T -> Async < Option < _ > >)
72
- : Async < Option < _ > > =
71
+ ( sequence : #seq<'T> , binder : 'T -> Async < _ option >)
72
+ : Async < _ option > =
73
73
this.Using( sequence.GetEnumerator (), fun enum ->
74
74
this.While( enum .MoveNext,
75
75
this.Delay( fun () -> binder enum .Current)))
@@ -79,13 +79,13 @@ module AsyncOptionCE =
79
79
///
80
80
/// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
81
81
/// </summary>
82
- member inline _.Source ( async : Async < Option < _ >> ) : Async < Option < _ > > = async
82
+ member inline _.Source ( async : Async < _ option > ) : Async < _ option > = async
83
83
84
84
#if ! FABLE_ COMPILER
85
85
/// <summary>
86
86
/// Method lets us transform data types into our internal representation.
87
87
/// </summary>
88
- member inline _.Source ( task : Task < Option < _ >> ) : Async < Option < _ > > = task |> Async.AwaitTask
88
+ member inline _.Source ( task : Task < _ option > ) : Async < _ option > = task |> Async.AwaitTask
89
89
#endif
90
90
91
91
let asyncOption = AsyncOptionBuilder()
@@ -105,7 +105,7 @@ module AsyncOptionCEExtensions =
105
105
/// <summary>
106
106
/// Method lets us transform data types into our internal representation.
107
107
/// </summary>
108
- member inline __.Source ( r : Option < 't > ) = Async.singleton r
108
+ member inline __.Source ( r : 't option ) = Async.singleton r
109
109
/// <summary>
110
110
/// Method lets us transform data types into our internal representation.
111
111
/// </summary>
@@ -116,4 +116,4 @@ module AsyncOptionCEExtensions =
116
116
/// Method lets us transform data types into our internal representation.
117
117
/// </summary>
118
118
member inline __.Source ( a : Task < 't >) = a |> Async.AwaitTask |> Async.map Some
119
- #endif
119
+ #endif
0 commit comments