private static ITry <ShoppingListWithItems, AddFoodstuffsError> Process(ApiResult <AddFoodstuffsToShoppingListResponse> response) => response.Match( s => Try.Success <ShoppingListWithItems, AddFoodstuffsError>(ToShoppingList(s)), e => Try.Error <ShoppingListWithItems, AddFoodstuffsError>(e.Message.Match( "Item already added.", _ => AddFoodstuffsError.FoodstuffAlreadyAdded )), noConn => throw new NotImplementedException()
private static ITry <Unit, SignUpError[]> Success() => Try.Success <Unit, SignUpError[]>(Unit.Value);
private static ITry <Unit, SignUpError[]> Error(IEnumerable <SignUpError> errors) => Try.Error <Unit, SignUpError[]>(errors.ToArray());
private static ITry <IAccount, SignInError> Success(IAccount a) => Try.Success <IAccount, SignInError>(a);
private static ITry <IAccount, SignInError> Error(SignInError e) => Try.Error <IAccount, SignInError>(e);
public static ITry <T, E> ToTry <T, E>(this bool b, Func <Unit, T> ifTrue, Func <Unit, E> ifFalse) { return(b ? Try.Success <T, E>(ifTrue(Unit.Value)) : Try.Error <T, E>(ifFalse(Unit.Value))); }