|
@@ -156,7 +156,9 @@ namespace Invercargill {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual Attempts<TOut> attempt_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
|
|
public virtual Attempts<TOut> attempt_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
|
|
|
- return select<Attempt<TOut>>(i => new Attempt<TOut>(() => transform(i))).assert_promotion<Attempts>();
|
|
|
|
|
|
|
+ // Promote this manually to preserve wrapped type
|
|
|
|
|
+ var attempts = new Attempts<TOut>();
|
|
|
|
|
+ return attempts.call_wrap(select<Attempt<TOut>>(i => new Attempt<TOut>(() => transform(i))));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual Attempts<SelectionContext<T, TOut>> attempt_contextualised_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
|
|
public virtual Attempts<SelectionContext<T, TOut>> attempt_contextualised_select<TOut>(owned AttemptTransformDelegate<T, TOut> transform) {
|
|
@@ -164,21 +166,26 @@ namespace Invercargill {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual Attempts<TOut> attempt_select_nested<TOut>(owned AttemptTransformDelegate<T, Enumerable<Attempt<TOut>>> transform) {
|
|
public virtual Attempts<TOut> attempt_select_nested<TOut>(owned AttemptTransformDelegate<T, Enumerable<Attempt<TOut>>> transform) {
|
|
|
- return attempt_select<Enumerable<Attempt<TOut>>>((owned)transform)
|
|
|
|
|
|
|
+ // Promote this manually to preserve wrapped type
|
|
|
|
|
+ var attempts = new Attempts<TOut>();
|
|
|
|
|
+ return attempts.call_wrap(
|
|
|
|
|
+ attempt_select<Enumerable<Attempt<TOut>>>((owned)transform)
|
|
|
.as_enumerable()
|
|
.as_enumerable()
|
|
|
.select_many<Attempt<TOut>>(a => a.success ? a.result : Iterate.single<Attempt<TOut>>(new Attempt<TOut>.unsuccessful(a.error)))
|
|
.select_many<Attempt<TOut>>(a => a.success ? a.result : Iterate.single<Attempt<TOut>>(new Attempt<TOut>.unsuccessful(a.error)))
|
|
|
- .assert_promotion<Attempts>();
|
|
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual Attempts<T> attempt_where(owned AttemptPredicate<T> predicate) {
|
|
public virtual Attempts<T> attempt_where(owned AttemptPredicate<T> predicate) {
|
|
|
- return select_where<Attempt<T>>((i, out o) => {
|
|
|
|
|
|
|
+ // Promote this manually to preserve wrapped type
|
|
|
|
|
+ var attempts = new Attempts<T>();
|
|
|
|
|
+ return attempts.call_wrap(select_where<Attempt<T>>((i, out o) => {
|
|
|
bool match = true;
|
|
bool match = true;
|
|
|
o = new Attempt<T>(() => {
|
|
o = new Attempt<T>(() => {
|
|
|
match = predicate(i);
|
|
match = predicate(i);
|
|
|
return i;
|
|
return i;
|
|
|
});
|
|
});
|
|
|
return match;
|
|
return match;
|
|
|
- }).assert_promotion<Attempts>();
|
|
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual Enumerable<Pair<TFirst, TSecond>> select_pairs<TFirst, TSecond>(owned TransformDelegate<T, TFirst> transform1, owned TransformDelegate<T, TSecond> transform2) {
|
|
public virtual Enumerable<Pair<TFirst, TSecond>> select_pairs<TFirst, TSecond>(owned TransformDelegate<T, TFirst> transform1, owned TransformDelegate<T, TSecond> transform2) {
|