Skip to content

Commit 1446d18

Browse files
committed
Add VOption to ToSeq
1 parent f0ca812 commit 1446d18

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/FSharpPlus/Control/Foldable.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ type ToSeq =
4848
#endif
4949
x
5050

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: 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: Id<'T> , [<Optional>]_impl: ToSeq) = Seq.singleton x.getValue
5556

5657
static member inline Invoke (source: '``Foldable<'T>``) : seq<'T> =
5758
let inline call_2 (a: ^a, b: ^b) = ((^a or ^b) : (static member ToSeq : _*_ -> _) b, a)

tests/FSharpPlus.Tests/Folds.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ module Folds =
2525
#endif
2626
let r1 = set [1..3] |> fold (+) 0
2727
let r2 = set [1..3] |> toSeq
28+
let r3 = ValueSome 1 |> toSeq
2829
Assert.AreEqual (6, r1)
2930
CollectionAssert.AreEqual ([1; 2; 3], r2)
31+
CollectionAssert.AreEqual ([1], r3)
3032
#if TEST_TRACE
3133
CollectionAssert.AreEqual (["ToSeq seq"], Traces.get())
3234
#endif

0 commit comments

Comments
 (0)