// Path: src/main/java/co/unruly/control/Piper.java
// public static <T> Piper<T> pipe(T element) {
//     return new Piper<T>(element);
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isFailureOf(F expectedValue) {
//     return isFailureThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isSuccessOf(S expectedValue) {
//     return isSuccessThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/result/Recover.java
// static <S, F> Function<F, Result<S, F>> ifIs(Predicate<F> test, Function<F, S> mapper) {
//     return input -> test.test(input)
//         ? Result.success(mapper.apply(input))
//         : Result.failure(input);
// }
// 
// Path: src/main/java/co/unruly/control/result/Introducers.java
// static <IS, OS, X extends Exception, F> Function<IS, Result<OS, F>> tryTo(
//     ThrowingLambdas.ThrowingFunction<IS, OS, X> throwingFunction,
//     Function<Exception, F> exceptionMapper
// ) {
//     return input -> {
//         try {
//             return Result.success(throwingFunction.apply(input));
//         } catch (Exception ex) {
//             return Result.failure(exceptionMapper.apply(ex));
//         }
//     };
// }
// 
// Path: src/main/java/co/unruly/control/result/Transformers.java
// static <IS, OS, F, OF extends F> Function<Result<IS, F>, Result<OS, F>> attempt(Function<IS, Result<OS, OF>> mappingFunction) {
//     return r -> r.either(mappingFunction.andThen(onFailure((Function<OF, F>) (fv) -> HigherOrderFunctions.upcast(fv))), Result::failure);
// }
// 
// Path: src/main/java/co/unruly/control/result/Transformers.java
// static <S, IF, OF> Function<Result<S, IF>, Result<S, OF>> onFailure(Function<IF, OF> mappingFunction) {
//     return recover(mappingFunction.andThen(Result::failure));
// }


import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static co.unruly.control.Piper.pipe;
import static co.unruly.control.matchers.ResultMatchers.isFailureOf;
import static co.unruly.control.matchers.ResultMatchers.isSuccessOf;
import static co.unruly.control.result.Recover.ifIs;
import static co.unruly.control.result.Introducers.tryTo;
import static co.unruly.control.result.Transformers.attempt;
import static co.unruly.control.result.Transformers.onFailure;
import static org.junit.Assert.assertThat;
package co.unruly.control.result;




public class PiperTest {

    @Test
    public void canChainSeveralOperationsBeforeOneWhichMayFail() {
        Pattern pattern = Pattern.compile("a=([^;]+);");

// Path: src/main/java/co/unruly/control/Piper.java
// public static <T> Piper<T> pipe(T element) {
//     return new Piper<T>(element);
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isFailureOf(F expectedValue) {
//     return isFailureThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isSuccessOf(S expectedValue) {
//     return isSuccessThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/result/Recover.java
// static <S, F> Function<F, Result<S, F>> ifIs(Predicate<F> test, Function<F, S> mapper) {
//     return input -> test.test(input)
//         ? Result.success(mapper.apply(input))
//         : Result.failure(input);
// }
// 
// Path: src/main/java/co/unruly/control/result/Introducers.java
// static <IS, OS, X extends Exception, F> Function<IS, Result<OS, F>> tryTo(
//     ThrowingLambdas.ThrowingFunction<IS, OS, X> throwingFunction,
//     Function<Exception, F> exceptionMapper
// ) {
//     return input -> {
//         try {
//             return Result.success(throwingFunction.apply(input));
//         } catch (Exception ex) {
//             return Result.failure(exceptionMapper.apply(ex));
//         }
//     };
// }
// 
// Path: src/main/java/co/unruly/control/result/Transformers.java
// static <IS, OS, F, OF extends F> Function<Result<IS, F>, Result<OS, F>> attempt(Function<IS, Result<OS, OF>> mappingFunction) {
//     return r -> r.either(mappingFunction.andThen(onFailure((Function<OF, F>) (fv) -> HigherOrderFunctions.upcast(fv))), Result::failure);
// }
// 
// Path: src/main/java/co/unruly/control/result/Transformers.java
// static <S, IF, OF> Function<Result<S, IF>, Result<S, OF>> onFailure(Function<IF, OF> mappingFunction) {
//     return recover(mappingFunction.andThen(Result::failure));
// }


// Path: src/test/java/co/unruly/control/result/PiperTest.java
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static co.unruly.control.Piper.pipe;
import static co.unruly.control.matchers.ResultMatchers.isFailureOf;
import static co.unruly.control.matchers.ResultMatchers.isSuccessOf;
import static co.unruly.control.result.Recover.ifIs;
import static co.unruly.control.result.Introducers.tryTo;
import static co.unruly.control.result.Transformers.attempt;
import static co.unruly.control.result.Transformers.onFailure;
import static org.junit.Assert.assertThat;

package co.unruly.control.result;




public class PiperTest {

    @Test
    public void canChainSeveralOperationsBeforeOneWhichMayFail() {
        Pattern pattern = Pattern.compile("a=([^;]+);");

        Result<Integer, String> result = pipe("a=1234;")