@@ -48,11 +48,12 @@ type ToSeq =
48
48
#endif
49
49
x
50
50
51
- static member ToSeq ( x : Text.StringBuilder , _ : ToSeq ) = string x :> seq< char>
52
- static member ToSeq ( x : string , _ : ToSeq ) = String.toSeq x
53
- static member ToSeq ( x : option < 'T > , [<Optional>] _impl : ToSeq ) = match x with Some x -> Seq.singleton x | _ -> Seq.empty
54
- static member ToSeq ( x : voption < 'T >, [<Optional>] _impl : ToSeq ) = match x with ValueSome x -> Seq.singleton x | _ -> Seq.empty
55
- static member ToSeq ( x : Id < 'T > , [<Optional>] _impl : ToSeq ) = Seq.singleton x.getValue
51
+ static member ToSeq ( x : Text.StringBuilder , _ : ToSeq ) = string x :> seq< char>
52
+ static member ToSeq ( x : string , _ : ToSeq ) = String.toSeq x
53
+ static member ToSeq ( x : option < 'T > , [<Optional>] _impl : ToSeq ) = match x with Some x -> Seq.singleton x | _ -> Seq.empty
54
+ static member ToSeq ( x : voption < 'T > , [<Optional>] _impl : ToSeq ) = match x with ValueSome x -> Seq.singleton x | _ -> Seq.empty
55
+ static member ToSeq ( x : Result < 'T , _ >, [<Optional>] _impl : ToSeq ) = match x with Ok x -> Seq.singleton x | _ -> Seq.empty
56
+ static member ToSeq ( x : Id < 'T > , [<Optional>] _impl : ToSeq ) = Seq.singleton x.getValue
56
57
57
58
static member inline Invoke ( source : '``Foldable < 'T > ``) : seq < 'T > =
58
59
let inline call_2 ( a : ^a , b : ^b ) = (( ^a or ^b ) : ( static member ToSeq : _*_ -> _) b, a)
@@ -120,6 +121,7 @@ type FoldBack =
120
121
static member FoldBack ( x : seq < _ > , f , z , [<Optional>] _impl : FoldBack ) = List.foldBack f ( Seq.toList x) z
121
122
static member FoldBack ( x : option < _ > , f , z , [<Optional>] _impl : FoldBack ) = match x with Some x -> f x z | _ -> z
122
123
static member FoldBack ( x : voption < _ > , f , z , [<Optional>] _impl : FoldBack ) = match x with ValueSome x -> f x z | _ -> z
124
+ static member FoldBack ( x : Result < _ , _ > , f , z , [<Optional>] _impl : FoldBack ) = match x with Ok x -> f x z | _ -> z
123
125
static member FoldBack ( x : list < _ > , f , z , [<Optional>] _impl : FoldBack ) = List.foldBack f x z
124
126
static member FoldBack ( x : _ [] , f , z , [<Optional>] _impl : FoldBack ) = Array.foldBack f x z
125
127
static member FoldBack ( x : Set < _ > , f , z , [<Optional>] _impl : FoldBack ) = Set.foldBack f x z
@@ -139,11 +141,12 @@ type FoldMap =
139
141
140
142
static member inline FromFoldFoldBack f x = FoldBack.Invoke ( Plus.Invoke << f) ( Zero.Invoke ()) x
141
143
142
- static member inline FoldMap ( x : option < _ > , f , [<Optional>] _impl : FoldMap ) = match x with Some x -> f x | _ -> Zero.Invoke ()
143
- static member inline FoldMap ( x : voption < _ >, f , [<Optional>] _impl : FoldMap ) = match x with ValueSome x -> f x | _ -> Zero.Invoke ()
144
- static member inline FoldMap ( x : list < _ > , f , [<Optional>] _impl : FoldMap ) = List.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
145
- static member inline FoldMap ( x : Set < _ > , f , [<Optional>] _impl : FoldMap ) = Seq.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
146
- static member inline FoldMap ( x : _ [] , f , [<Optional>] _impl : FoldMap ) = Array.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
144
+ static member inline FoldMap ( x : option < _ > , f , [<Optional>] _impl : FoldMap ) = match x with Some x -> f x | _ -> Zero.Invoke ()
145
+ static member inline FoldMap ( x : voption < _ > , f , [<Optional>] _impl : FoldMap ) = match x with ValueSome x -> f x | _ -> Zero.Invoke ()
146
+ static member inline FoldMap ( x : Result < _ , _ >, f , [<Optional>] _impl : FoldMap ) = match x with Ok x -> f x | _ -> Zero.Invoke ()
147
+ static member inline FoldMap ( x : list < _ > , f , [<Optional>] _impl : FoldMap ) = List.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
148
+ static member inline FoldMap ( x : Set < _ > , f , [<Optional>] _impl : FoldMap ) = Seq.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
149
+ static member inline FoldMap ( x : _ [] , f , [<Optional>] _impl : FoldMap ) = Array.fold ( fun x y -> Plus.Invoke x ( f y)) ( Zero.Invoke ()) x
147
150
148
151
static member inline Invoke ( f : 'T -> 'Monoid ) ( x : '``Foldable' < T > ``) : 'Monoid =
149
152
let inline call_2 ( a : ^a , b : ^b , f ) = (( ^a or ^b ) : ( static member FoldMap : _*_*_ -> _) b, f, a)
@@ -174,14 +177,15 @@ type Fold =
174
177
#endif
175
178
Seq.fold f z ( ToSeq.Invoke x)
176
179
177
- static member inline Fold ( x : 'F , f : 'b -> 'a -> 'b , z : 'b , [<Optional>] _impl : Default1 ) = ( ^F : ( static member Fold : ^F -> _ -> _ -> ^b ) x, f, z)
178
- static member Fold ( x : option < _ > , f , z , [<Optional>] _impl : Fold ) = match x with Some x -> f z x | _ -> z
179
- static member Fold ( x : voption < _ >, f , z , [<Optional>] _impl : Fold ) = match x with ValueSome x -> f z x | _ -> z
180
- static member Fold ( x : Id < _ > , f , z , [<Optional>] _impl : Fold ) = f z x.getValue
181
- static member Fold ( x : seq < _ > , f , z , [<Optional>] _impl : Fold ) = Seq.fold f z x
182
- static member Fold ( x : list < _ > , f , z , [<Optional>] _impl : Fold ) = List.fold f z x
183
- static member Fold ( x : Set < _ > , f , z , [<Optional>] _impl : Fold ) = Set.fold f z x
184
- static member Fold ( x : _ [] , f , z , [<Optional>] _impl : Fold ) = Array.fold f z x
180
+ static member inline Fold ( x : 'F , f : 'b -> 'a -> 'b , z : 'b , [<Optional>] _impl : Default1 ) = ( ^F : ( static member Fold : ^F -> _ -> _ -> ^b ) x, f, z)
181
+ static member Fold ( x : option < _ > , f , z , [<Optional>] _impl : Fold ) = match x with Some x -> f z x | _ -> z
182
+ static member Fold ( x : voption < _ > , f , z , [<Optional>] _impl : Fold ) = match x with ValueSome x -> f z x | _ -> z
183
+ static member Fold ( x : Result < _ , _ >, f , z , [<Optional>] _impl : Fold ) = match x with Ok x -> f z x | _ -> z
184
+ static member Fold ( x : Id < _ > , f , z , [<Optional>] _impl : Fold ) = f z x.getValue
185
+ static member Fold ( x : seq < _ > , f , z , [<Optional>] _impl : Fold ) = Seq.fold f z x
186
+ static member Fold ( x : list < _ > , f , z , [<Optional>] _impl : Fold ) = List.fold f z x
187
+ static member Fold ( x : Set < _ > , f , z , [<Optional>] _impl : Fold ) = Set.fold f z x
188
+ static member Fold ( x : _ [] , f , z , [<Optional>] _impl : Fold ) = Array.fold f z x
185
189
186
190
static member inline Invoke ( folder : 'State -> 'T -> 'State ) ( state : 'State ) ( foldable : '``Foldable' < T > ``) : 'State =
187
191
let inline call_2 ( a : ^a , b : ^b , f , z ) = (( ^a or ^b ) : ( static member Fold : _*_*_*_ -> _) b, f, z, a)
@@ -198,7 +202,7 @@ type Exists =
198
202
static member Exists ( x : 'a [] , f , [<Optional>] _impl : Exists ) = Array.exists f x
199
203
static member Exists ( x : Set < 'a > , f , [<Optional>] _impl : Exists ) = Set.exists f x
200
204
static member Exists ( x : 'a ResizeArray , f , [<Optional>] _impl : Exists ) = Seq.exists f x
201
- static member Exists ( x : string , f , [<Optional>] _impl : Exists ) = String.exists f x
205
+ static member Exists ( x : string , f , [<Optional>] _impl : Exists ) = String.exists f x
202
206
static member Exists ( x : StringBuilder , f , [<Optional>] _impl : Exists ) = x |> string |> String.exists f
203
207
204
208
static member inline Invoke ( predicate : 'T -> bool ) ( source : '``Foldable' < T > ``) =
@@ -260,6 +264,7 @@ type Head =
260
264
static member inline Head ( x : '``Foldable < 'T > ``, [<Optional>] _impl : Default1 ) = (^ `` Foldable<'T> `` : ( member Head : 'T) x)
261
265
static member Head ( x : 'T option , [<Optional>] _impl : Head ) = x.Value
262
266
static member Head ( x : 'T voption , [<Optional>] _impl : Head ) = x.Value
267
+ static member Head ( x : Result < _ , _ > , [<Optional>] _impl : Head ) = Result.get x
263
268
static member Head ( x : 'T [] , [<Optional>] _impl : Head ) = x.[ 0 ]
264
269
static member Head ( x : NonEmptySeq < 'T > , [<Optional>] _impl : Head ) = x.First
265
270
static member Head ( x : Id < 'T > , [<Optional>] _impl : Head ) = x.getValue
@@ -420,6 +425,7 @@ type Length =
420
425
static member Length ( x : 'T list , [<Optional>] _impl : Length ) = List.length x
421
426
static member Length ( x : option < 'T > , [<Optional>] _impl : Length ) = if x.IsSome then 1 else 0
422
427
static member Length ( x : voption < 'T > , [<Optional>] _impl : Length ) = if x.IsSome then 1 else 0
428
+ static member Length ( x : Result < _ , _ > , [<Optional>] _impl : Length ) = if x.IsOk then 1 else 0
423
429
static member Length ( x : 'T [] , [<Optional>] _impl : Length ) = Array.length x
424
430
425
431
static member inline Invoke ( source : '``Foldable < 'T > ``) =
0 commit comments