You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
418
406
memberx.MoveNext()= monad' {
419
407
match state with
420
408
| CollectState.NotStarted inp ->
@@ -458,10 +446,7 @@ module SeqT_V2 =
458
446
let mutablestate= CollectState.NotStarted f
459
447
let mutablecurrent= Option<'U>.None
460
448
{new IEnumeratorM<'``Monad<bool>``, 'U>with
461
-
member_.Current=
462
-
match current with
463
-
| Some c -> c
464
-
| None -> invalidOp enumNotStarted
449
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
465
450
memberx.MoveNext()= monad' {
466
451
match state with
467
452
| CollectState.NotStarted f ->
@@ -505,10 +490,7 @@ module SeqT_V2 =
505
490
let mutablestate= CollectState.NotStarted x1
506
491
let mutablecurrent= Option<'U>.None
507
492
{new IEnumeratorM<'``Monad<bool>``, 'U>with
508
-
member_.Current=
509
-
match current with
510
-
| Some c -> c
511
-
| None -> invalidOp enumNotStarted
493
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
512
494
memberx.MoveNext()= monad' {
513
495
match state with
514
496
| CollectState.NotStarted x1 ->
@@ -560,10 +542,7 @@ module SeqT_V2 =
560
542
let mutablestate= AppendState.NotStarted1 (source1, source2)
561
543
let mutablecurrent= Option<'T>.None
562
544
{new IEnumeratorM<'``Monad<bool>``, 'T>with
563
-
member_.Current=
564
-
match current with
565
-
| Some c -> c
566
-
| None -> invalidOp enumNotStarted
545
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
567
546
memberx.MoveNext()= innerMonad {
568
547
match state with
569
548
| AppendState.NotStarted1 (inp1, inp2)->
@@ -621,10 +600,7 @@ module SeqT_V2 =
621
600
let mutablestate= MapState.NotStarted source
622
601
let mutablecurrent= Option<'U>.None
623
602
{new IEnumeratorM<'``Monad<bool>``, 'U>with
624
-
member_.Current=
625
-
match current with
626
-
| Some c -> c
627
-
| None -> invalidOp enumNotStarted
603
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
628
604
memberx.MoveNext()= innerMonad {
629
605
match state with
630
606
| MapState.NotStarted inp ->
@@ -661,10 +637,7 @@ module SeqT_V2 =
661
637
let mutablestate= Map2State.NotStarted (source1, source2)
662
638
let mutablecurrent= Option<'U>.None
663
639
{new IEnumeratorM<'``Monad<bool>``, 'U>with
664
-
member_.Current=
665
-
match current with
666
-
| Some c -> c
667
-
| None -> invalidOp enumNotStarted
640
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
668
641
memberx.MoveNext()= innerMonad {
669
642
match state with
670
643
| Map2State.NotStarted (s1, s2)->return!(
@@ -697,10 +670,7 @@ module SeqT_V2 =
697
670
let mutablestate= Map2State.NotStarted (source1, source2)
698
671
let mutablecurrent= Option<'U>.None
699
672
{new IEnumeratorM<'``Monad<bool>``, 'U>with
700
-
member_.Current=
701
-
match current with
702
-
| Some c -> c
703
-
| None -> invalidOp enumNotStarted
673
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
704
674
memberx.MoveNext()= innerMonad {
705
675
match state with
706
676
| Map2State.NotStarted (s1, s2)->
@@ -750,10 +720,7 @@ module SeqT_V2 =
750
720
let mutablestate= CollectState.NotStarted source
751
721
let mutablecurrent= Option<'T>.None
752
722
{new IEnumeratorM<'``Monad<bool>``, 'T>with
753
-
member_.Current=
754
-
match current with
755
-
| Some c -> c
756
-
| None -> invalidOp enumNotStarted
723
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
757
724
memberx.MoveNext()= innerMonad {
758
725
match state with
759
726
| CollectState.NotStarted inp ->
@@ -799,7 +766,7 @@ module SeqT_V2 =
799
766
800
767
let inlineinternaltryPickMAndMap<'T,'U,..>(f:'T ->'``Monad<'Uoption>``)(source:SeqT<'``Monad<bool>``,'T>)(postMap:'U option ->'V):'``Monad<'V>`` = innerMonad2<_, '``Monad<unit>``>(){
801
768
use ie =(source :> IEnumerableM<'``Monad<bool>``, 'T>).GetEnumerator ()
802
-
let!(move:bool)= ie.MoveNext ()
769
+
let!move= ie.MoveNext ()
803
770
let mutableb= move
804
771
let mutableres= None
805
772
while b && res.IsNone do
@@ -813,7 +780,7 @@ module SeqT_V2 =
813
780
814
781
let inlineinternaltryPickAndMap<'T,'U,..>(f:'T ->'U option)(source:SeqT<'``Monad<bool>``,'T>)(postMap:'U option ->'V):'``Monad<'V>`` = innerMonad2<_, '``Monad<unit>``>(){
815
782
use ie =(source :> IEnumerableM<'``Monad<bool>``, 'T>).GetEnumerator ()
816
-
let!(move:bool)= ie.MoveNext ()
783
+
let!move= ie.MoveNext ()
817
784
let mutableb= move
818
785
let mutableres= None
819
786
while b && res.IsNone do
@@ -829,13 +796,13 @@ module SeqT_V2 =
829
796
tryPickMAndMap<_, 'U,_, '``Monad<unit>``,_,_,_> f source id
830
797
831
798
let inlinepickM<'T,'U,..>(f:'T ->'``Monad<'Uoption>``)(source:SeqT<'``Monad<bool>``,'T>):'``Monad<'U>`` =
832
-
tryPickMAndMap<_, 'U, '``Monad<'U option>``, '``Monad<unit>``,_,_,_> f source (function Some v ->(v: 'U)|_-> raise (KeyNotFoundException ()))
799
+
tryPickMAndMap<_, 'U, '``Monad<'U option>``, '``Monad<unit>``,_,_,_> f source (function Some v ->v|_-> raise (KeyNotFoundException ()))
833
800
834
801
let inlinetryPick<'T,'U,..>(f:'T ->'U option)(source:SeqT<'``Monad<bool>``,'T>):'``Monad<'Uoption>`` =
835
802
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_> f source id
836
803
837
804
let inlinepick(f:'T ->'U option)(source:SeqT<'``Monad<bool>``,'T>):'``Monad<'U>`` =
838
-
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_> f source (function Some v ->(v: 'U)|_-> raise (KeyNotFoundException ()))
805
+
tryPickAndMap<_,'U,_,_, '``Monad<unit>``,_> f source (function Some v ->v|_-> raise (KeyNotFoundException ()))
839
806
840
807
let inlinecontains value (source:SeqT<'``Monad<bool>``,'T>):'``Monad<bool>`` =
841
808
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_>(fun v ->if v = value then Some ()else None) source Option.isSome
@@ -844,7 +811,7 @@ module SeqT_V2 =
844
811
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_>(fun v ->if f v then Some v else None) source id
845
812
846
813
let inlinefind f (source:SeqT<'``Monad<bool>``,'T>):'``Monad<'T>`` =
847
-
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_>(fun v ->if f v then Some v else None) source (function Some v ->(v: 'T)|_-> raise (KeyNotFoundException ()))
814
+
tryPickAndMap<'T,_,_,_, '``Monad<unit>``,_>(fun v ->if f v then Some v else None) source (function Some v ->v|_-> raise (KeyNotFoundException ()))
848
815
849
816
let inlineexists f (source:SeqT<'``Monad<bool>``,'T>):'``Monad<bool>`` =
850
817
tryPickAndMap<_,_,_,_, '``Monad<unit>``,_>(fun v ->if f v then Some v else None) source Option.isSome
@@ -867,10 +834,7 @@ module SeqT_V2 =
867
834
let mutablestate= TryWithState.NotStarted source
868
835
let mutablecurrent= Option<'T>.None
869
836
{new IEnumeratorM<'``Monad<bool>``, 'T>with
870
-
member_.Current=
871
-
match current with
872
-
| Some c -> c
873
-
| None -> invalidOp enumNotStarted
837
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
let mutablestate= TryFinallyState.NotStarted source
940
904
let mutablecurrent= Option<'T>.None
941
905
{new IEnumeratorM<'``Monad<bool>``, 'T>with
942
-
member_.Current=
943
-
match current with
944
-
| Some c -> c
945
-
| None -> invalidOp enumNotStarted
906
+
member_.Current= Option.defaultWith (fun()-> invalidOp enumNotStarted) current
946
907
memberx.MoveNext()= innerMonad {
947
908
match state with
948
909
| TryFinallyState.NotStarted inp ->
@@ -1003,7 +964,7 @@ module SeqT_V2 =
1003
964
///
1004
965
/// <exception cref="T:System.ArgumentNullException">Thrown when count is negative.</exception>
1005
966
let inlinetruncate count (source:SeqT<'``Monad<bool>``,'T>):SeqT<'``Monad<bool>``,'T>=
1006
-
if(count <0)then invalidArg "count""must be non-negative"
967
+
if count <0then invalidArg "count""must be non-negative"
1007
968
SeqT
1008
969
{new IEnumerableM<'``Monad<bool>``, 'T>with
1009
970
member_.GetEnumerator()=
@@ -1035,7 +996,7 @@ module SeqT_V2 =
1035
996
/// <exception cref="T:System.InvalidOperationException">Thrown when count exceeds the number of elements.
1036
997
/// in the sequence.</exception>
1037
998
let inlinetake count (source:SeqT<'``Monad<bool>``,'T>):SeqT<'``Monad<bool>``,'T>=
1038
-
if(count <0)then invalidArg "count""must be non-negative"
999
+
if count <0then invalidArg "count""must be non-negative"
1039
1000
SeqT
1040
1001
{new IEnumerableM<'``Monad<bool>``, 'T>with
1041
1002
member_.GetEnumerator()=
@@ -1047,20 +1008,15 @@ module SeqT_V2 =
1047
1008
if i >0then
1048
1009
i <- i -1
1049
1010
e.MoveNext ()|> monomorphicBind (fun res ->
1050
-
ifnot res then invalidOp (
1051
-
sprintf
1052
-
"The input sequence has an insufficient number of elements: tried to take %i%s past the end of the sequence. Use SeqT.truncate to get %i or less elements."
1053
-
(i +1)
1054
-
(if i =0then"element"else"elements")
1055
-
count)
1011
+
ifnot res then invalidOp $"The input sequence has an insufficient number of elements: tried to take {i + 1} element{if i = 0 then String.Empty else string 's'} past the end of the sequence. Use SeqT.truncate to get {count} or less elements."
1056
1012
result res)
1057
1013
else
1058
1014
x.Dispose ()
1059
1015
result false
1060
1016
member_.Dispose()= dispose e }}
1061
1017
1062
1018
let inlineinternalskipImpl throw count (source:SeqT<'``Monad<bool>``,'T>):SeqT<'``Monad<bool>``,'T>=
1063
-
if(count <0)then invalidArg "count""must be non-negative"
1019
+
if count <0then invalidArg "count""must be non-negative"
1064
1020
SeqT
1065
1021
{new IEnumerableM<'``Monad<bool>``, 'T>with
1066
1022
member_.GetEnumerator()=
@@ -1072,23 +1028,14 @@ module SeqT_V2 =
1072
1028
if i >0then
1073
1029
i <- i -1
1074
1030
e.MoveNext ()|> monomorphicBind (fun res ->
1075
-
if res then
1076
-
x.MoveNext ()
1031
+
if res then x.MoveNext ()
1032
+
elif throw then invalidOp $"Tried to skip {i + 1} element{if i = 0 then String.Empty else string 's'} past the end of the seq. Use SeqT.drop to skip {count} or less elements."
1077
1033
else
1078
-
if throw then
1079
-
invalidOp (
1080
-
sprintf
1081
-
"tried to skip %i%s past the end of the seq. Use SeqT.drop to skip %i or less elements."
0 commit comments