Skip to content

Commit c939b9f

Browse files
committed
Merge branch 'master' into v1.6
2 parents 7240145 + cc6ca3d commit c939b9f

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

RELEASE_NOTES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#### 1.6.0 - January 29 2024
1+
#### 1.6.1 - February 13 2024
22
- Add Non-sequential-Applicative operators and computation expressions
33
- Add proper SeqT implementation
44
- Matrix and Vector types implement IEnumerable's and IReadOnly's interfaces
@@ -11,7 +11,11 @@
1111
- Add Result.iterError
1212
- Add Validation.ofOptionWith
1313
- Add List.chunkBy
14+
- Rename Sequence overloads to Sequential
15+
- Add Async.Await Async.AsTask and more overloads to Async.Sequential
16+
- Add empty and isEmpty to IReadOnlyCollection and Exception module
1417
- Fix bug in lift3 for List and Array
18+
- Type inference for generic traversals slightly improved
1519

1620
#### 1.5.0 - October 15 2023
1721
- Support for Fable 4 (some functions had to be removed from Fable in order to it)

RELEASE_NOTES.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Release Notes for FSharpPlus 1.6.0 - January 29 2024
2-
-----------------------------------------------------
1+
Release Notes for FSharpPlus 1.6.1 - February 13 2024
2+
------------------------------------------------------
33

44
Add Non-sequential-Applicative operators and computation expressions
55
Add proper SeqT implementation
@@ -13,4 +13,8 @@ Add Result.Sequence
1313
Add Result.iterError
1414
Add Validation.ofOptionWith
1515
Add List.chunkBy
16-
Fix bug in lift3 for List and Array
16+
Rename Sequence overloads to Sequential
17+
Add Async.Await Async.AsTask and more overloads to Async.Sequential
18+
Add empty and isEmpty to IReadOnlyCollection and Exception module
19+
Fix bug in lift3 for List and Array
20+
Type inference for generic traversals slightly improved

src/FSharpPlus/Control/Traversable.fs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ type Sequence =
1616
static member inline InvokeOnInstance (t: '``Traversable<'Functor<'T>>``) = (^``Traversable<'Functor<'T>>`` : (static member Sequence : _ -> _) t) : '``Functor<'Traversable<'T>>``
1717

1818
[<EditorBrowsable(EditorBrowsableState.Never)>]
19-
static member inline ForInfiniteSequences (t: seq<_>, isFailure, conversion) =
19+
static member inline ForInfiniteSequences (t: seq<_>, [<InlineIfLambda>]isFailure, [<InlineIfLambda>]conversion, [<InlineIfLambda>]result) =
2020
let add x y = y :: x
2121
let mutable go = true
22-
let mutable r = result []
22+
let mutable r = Unchecked.defaultof<_>
23+
let mutable isEmpty = true
2324
use e = t.GetEnumerator ()
2425
while go && e.MoveNext () do
2526
if isFailure e.Current then go <- false
26-
r <- Map.Invoke add r <*> e.Current
27-
Map.Invoke (List.rev >> conversion) r
27+
if isEmpty then r <- Map.Invoke List.singleton e.Current
28+
else r <- Map.Invoke add r <*> e.Current
29+
isEmpty <- false
30+
if isEmpty then result (conversion [])
31+
else Map.Invoke (List.rev >> conversion) r
2832

2933
type Traverse =
3034
inherit Default1
@@ -64,14 +68,14 @@ type Traverse =
6468
Traces.add "Traverse seq, 'T -> Functor<'U>"
6569
#endif
6670
let mapped = Seq.map f t
67-
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, List.toSeq) : '``Functor<seq<'U>>``
71+
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, List.toSeq, Return.Invoke) : '``Functor<seq<'U>>``
6872

6973
static member inline Traverse (t: NonEmptySeq<'T>, f: 'T -> '``Functor<'U>``, [<Optional>]_output: '``Functor<NonEmptySeq<'U>>``, [<Optional>]_impl: Default2) =
7074
#if TEST_TRACE
7175
Traces.add "Traverse NonEmptySeq, 'T -> Functor<'U>"
7276
#endif
7377
let mapped = NonEmptySeq.map f t
74-
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq.ofList) : '``Functor<NonEmptySeq<'U>>``
78+
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq.ofList, Return.Invoke) : '``Functor<NonEmptySeq<'U>>``
7579

7680
static member inline Traverse (t: ^a, f, [<Optional>]_output: 'R, [<Optional>]_impl: Default1) : 'R =
7781
#if TEST_TRACE
@@ -191,26 +195,26 @@ type Sequence with
191195
Seq.foldBack cons_f t (result Seq.empty)
192196

193197
static member inline Sequence (t: seq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<seq<'T>>`` , [<Optional>]_impl: Default4) : '``Applicative<seq<'T>>`` =
194-
Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, List.toSeq)
198+
Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, List.toSeq, Return.Invoke)
195199

196200
static member Sequence (t: seq<option<'t>> , [<Optional>]_output: option<seq<'t>> , [<Optional>]_impl: Default3) : option<seq<'t>> = Option.Sequential t
197201
#if !FABLE_COMPILER
198202
static member Sequence (t: seq<voption<'t>> , [<Optional>]_output: voption<seq<'t>> , [<Optional>]_impl: Default3) : voption<seq<'t>> = ValueOption.Sequential t
199203
#endif
200204
static member Sequence (t: seq<Result<'t,'e>>, [<Optional>]_output: Result<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<seq<'t>, 'e> = Result.Sequential t
201205
static member Sequence (t: seq<Choice<'t,'e>>, [<Optional>]_output: Choice<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<seq<'t>, 'e> = Choice.Sequential t
202-
static member Sequence (t: seq<list<'t>> , [<Optional>]_output: list<seq<'t>> , [<Optional>]_impl: Default3) : list<seq<'t>> = Sequence.ForInfiniteSequences (t, List.isEmpty, List.toSeq)
203-
static member Sequence (t: seq<'t []> , [<Optional>]_output: seq<'t> [] , [<Optional>]_impl: Default3) : seq<'t> [] = Sequence.ForInfiniteSequences (t, Array.isEmpty, List.toSeq)
206+
static member Sequence (t: seq<list<'t>> , [<Optional>]_output: list<seq<'t>> , [<Optional>]_impl: Default3) : list<seq<'t>> = Sequence.ForInfiniteSequences (t, List.isEmpty, List.toSeq, List.singleton)
207+
static member Sequence (t: seq<'t []> , [<Optional>]_output: seq<'t> [] , [<Optional>]_impl: Default3) : seq<'t> [] = Sequence.ForInfiniteSequences (t, Array.isEmpty, List.toSeq, Array.singleton)
204208

205209
#if !FABLE_COMPILER
206210
static member Sequence (t: seq<Async<'t>> , [<Optional>]_output: Async<seq<'t>> , [<Optional>]_impl: Default3) : Async<seq<'t>> = Async.SequentialLazy t
207211
#endif
208-
static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<NonEmptySeq<'T>>`` , [<Optional>]_impl: Default4) : '``Applicative<NonEmptySeq<'T>>`` = Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq.ofList)
212+
static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<NonEmptySeq<'T>>``, [<Optional>]_impl: Default4) : '``Applicative<NonEmptySeq<'T>>`` = Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>)
209213
static member Sequence (t: NonEmptySeq<option<'t>> , [<Optional>]_output: option<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : option<NonEmptySeq<'t>> = Option.Sequential t |> Option.map NonEmptySeq.unsafeOfSeq
210214
static member Sequence (t: NonEmptySeq<Result<'t,'e>>, [<Optional>]_output: Result<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<NonEmptySeq<'t>, 'e> = Result.Sequential t |> Result.map NonEmptySeq.unsafeOfSeq
211215
static member Sequence (t: NonEmptySeq<Choice<'t,'e>>, [<Optional>]_output: Choice<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<NonEmptySeq<'t>, 'e> = Choice.Sequential t |> Choice.map NonEmptySeq.unsafeOfSeq
212-
static member Sequence (t: NonEmptySeq<list<'t>> , [<Optional>]_output: list<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : list<NonEmptySeq<'t>> = Sequence.ForInfiniteSequences(t, List.isEmpty , NonEmptySeq.ofList)
213-
static member Sequence (t: NonEmptySeq<'t []> , [<Optional>]_output: NonEmptySeq<'t> [] , [<Optional>]_impl: Default3) : NonEmptySeq<'t> [] = Sequence.ForInfiniteSequences(t, Array.isEmpty, NonEmptySeq.ofList)
216+
static member Sequence (t: NonEmptySeq<list<'t>> , [<Optional>]_output: list<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : list<NonEmptySeq<'t>> = Sequence.ForInfiniteSequences(t, List.isEmpty , NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>)
217+
static member Sequence (t: NonEmptySeq<'t []> , [<Optional>]_output: NonEmptySeq<'t> [] , [<Optional>]_impl: Default3) : NonEmptySeq<'t> [] = Sequence.ForInfiniteSequences(t, Array.isEmpty, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>)
214218
#if !FABLE_COMPILER
215219
static member Sequence (t: NonEmptySeq<Async<'t>> , [<Optional>]_output: Async<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) = Async.SequentialLazy t |> Async.map NonEmptySeq.unsafeOfSeq : Async<NonEmptySeq<'t>>
216220
#endif
@@ -222,7 +226,7 @@ type Sequence with
222226
#if !FABLE_COMPILER
223227
static member inline Sequence (t: voption<_>, [<Optional>]_output: 'R, [<Optional>]_impl: Sequence) : 'R = match t with ValueSome x -> Map.Invoke ValueSome x | _ -> result ValueNone
224228
#endif
225-
static member inline Sequence (t: list<_> , [<Optional>]_output: 'R, [<Optional>]_impl: Sequence) : 'R = Sequence.ForInfiniteSequences(t, IsLeftZero.Invoke, id)
229+
static member inline Sequence (t: list<_> , [<Optional>]_output: 'R, [<Optional>]_impl: Sequence) : 'R = Sequence.ForInfiniteSequences(t, IsLeftZero.Invoke, id, Return.Invoke)
226230

227231
static member inline Sequence (t: Map<_,_> , [<Optional>]_output: 'R, [<Optional>]_impl: Sequence) : 'R =
228232
let insert_f k x ys = Map.Invoke (Map.add k) x <*> ys
@@ -238,7 +242,7 @@ type Sequence with
238242
| Choice1Of2 a -> Map.Invoke Choice<'T,'Error>.Choice1Of2 a
239243
| Choice2Of2 e -> Return.Invoke (Choice<'T,'Error>.Choice2Of2 e)
240244

241-
static member inline Sequence (t: _ [] , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) : 'R = Sequence.ForInfiniteSequences(t, IsLeftZero.Invoke, Array.ofList)
245+
static member inline Sequence (t: _ [] , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) : 'R = Sequence.ForInfiniteSequences(t, IsLeftZero.Invoke, Array.ofList, Return.Invoke)
242246

243247
static member inline Sequence (t: Id<'``Functor<'T>``> , [<Optional>]_output: '``Functor<Id<'T>>`` , [<Optional>]_impl: Sequence) : '``Functor<Id<'T>>`` = Traverse.Invoke id t
244248

tests/FSharpPlus.Tests/Asyncs.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module Async =
103103

104104
let t123 = Async.map3 (fun x y z -> [x; y; z]) t1 t2 t3
105105
let t123' = transpose [t1; t2; t3]
106-
let t123'' = sequence [t1; t2; t3] : Async<int list>
106+
let t123'' = sequence [t1; t2; t3]
107107
CollectionAssert.AreEquivalent ((Async.AsTaskAndWait t123).Exception.InnerExceptions, (Async.AsTaskAndWait t123').Exception.InnerExceptions, "Async.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is the same as transpose [t1; t2; t3]")
108108
CollectionAssert.AreNotEquivalent ((Async.AsTaskAndWait t123).Exception.InnerExceptions, (Async.AsTaskAndWait t123'').Exception.InnerExceptions, "Async.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is not the same as sequence [t1; t2; t3]")
109109

tests/FSharpPlus.Tests/Traversals.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module Traversable =
115115
// It hangs if we try to share this value between tests
116116
let expectedEffects =
117117
[
118-
"""f(x) <*> Right 0"""
118+
// map does this -> """f(x) <*> Right 0"""
119119
"""f(x) <*> Right 1"""
120120
"""f(x) <*> Right 2"""
121121
"""f(x) <*> Right 3"""
@@ -180,7 +180,7 @@ module Traversable =
180180
// It hangs if we try to share this value between tests
181181
let expectedEffects =
182182
[
183-
"""f(x) <*> Right 0"""
183+
// map does this -> """f(x) <*> Right 0"""
184184
"""f(x) <*> Right 1"""
185185
"""f(x) <*> Right 2"""
186186
"""f(x) <*> Right 3"""

tests/FSharpPlusFable.Tests/FSharpTests/General/Traversable.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ let traversable = testList "Traversable" [
135135

136136
let expectedEffects =
137137
[
138-
"""f(x) <*> Right 0"""
138+
// map does this -> """f(x) <*> Right 0"""
139139
"""f(x) <*> Right 1"""
140140
"""f(x) <*> Right 2"""
141141
"""f(x) <*> Right 3"""
@@ -243,7 +243,7 @@ let traversable = testList "Traversable" [
243243
testCase "e" (fun () ->
244244
let expectedEffects =
245245
[
246-
"""f(x) <*> Right 0"""
246+
// map does this -> """f(x) <*> Right 0"""
247247
"""f(x) <*> Right 1"""
248248
"""f(x) <*> Right 2"""
249249
"""f(x) <*> Right 3"""
@@ -262,7 +262,7 @@ let traversable = testList "Traversable" [
262262
testCase "f" (fun () ->
263263
let expectedEffects =
264264
[
265-
"""f(x) <*> Right 0"""
265+
// map does this -> """f(x) <*> Right 0"""
266266
"""f(x) <*> Right 1"""
267267
"""f(x) <*> Right 2"""
268268
"""f(x) <*> Right 3"""

0 commit comments

Comments
 (0)