// Path: src/main/java/com/shapesecurity/functional/Effect.java
// @FunctionalInterface
// public interface Effect<A> extends F<A, Unit> {
//     void e(@Nonnull A a);
// 
//     @Nonnull
//     default Unit apply(@Nonnull A a) {
//         this.e(a);
//         return Unit.unit;
//     }
// }
// 
// Path: src/main/java/com/shapesecurity/functional/F.java
// @CheckReturnValue
// @FunctionalInterface
// public interface F<A, R> {
//     @Nonnull
//     static <A extends B, B> F<A, B> id() {
//         return o -> o;
//     }
// 
//     @Nonnull
//     static <A, B> F<A, B> constant(@Nonnull final B b) {
//         return a -> b;
//     }
// 
//     @Nonnull
//     static <A, B, C> F2<A, B, C> uncurry(@Nonnull final F<A, F<B, C>> f) {
//         return (a, b) -> f.apply(a).apply(b);
//     }
// 
//     @Nonnull
//     static <A, B, C> F<B, F<A, C>> flip(@Nonnull final F<A, F<B, C>> f) {
//         return b -> a -> f.apply(a).apply(b);
//     }
// 
//     @Nonnull
//     R apply(@Nonnull A a);
// 
//     @Nonnull
//     default <C> F<C, R> compose(@Nonnull final F<C, A> f) {
//         return c -> this.apply(f.apply(c));
//     }
// 
// 
//     @Nonnull
//     default <B> F<A, B> then(@Nonnull final F<R, B> f) {
//         return c -> f.apply(this.apply(c));
//     }
// }
// 
// Path: src/main/java/com/shapesecurity/functional/ThrowingSupplier.java
// @FunctionalInterface
// public interface ThrowingSupplier<A> {
//     A get() throws Exception;
// }


import com.shapesecurity.functional.Effect;
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.ThrowingSupplier;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
/*
 * Copyright 2014 Shape Security, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shapesecurity.functional.data;



@CheckReturnValue
public final class Either<A, B> {
    private final Object data;

    private enum Tag {
        LEFT, RIGHT
    }

    private final Tag tag;

    // class local
    private Either(Object data, Tag tag) {
        super();
        this.data = data;
        this.tag = tag;
    }

    @Nonnull
    public static <A, B> Either<A, B> left(@Nonnull A a) {
        return new Either<>(a, Tag.LEFT);
    }

    @Nonnull
    public static <A, B> Either<A, B> right(@Nonnull B b) {
        return new Either<>(b, Tag.RIGHT);
    }

    @Nonnull
    public static <A, B extends A, C extends A> A extract(Either<B, C> e) {
        return e.either(x -> x, x -> x);
    }

    @Nonnull
// Path: src/main/java/com/shapesecurity/functional/Effect.java
// @FunctionalInterface
// public interface Effect<A> extends F<A, Unit> {
//     void e(@Nonnull A a);
// 
//     @Nonnull
//     default Unit apply(@Nonnull A a) {
//         this.e(a);
//         return Unit.unit;
//     }
// }
// 
// Path: src/main/java/com/shapesecurity/functional/F.java
// @CheckReturnValue
// @FunctionalInterface
// public interface F<A, R> {
//     @Nonnull
//     static <A extends B, B> F<A, B> id() {
//         return o -> o;
//     }
// 
//     @Nonnull
//     static <A, B> F<A, B> constant(@Nonnull final B b) {
//         return a -> b;
//     }
// 
//     @Nonnull
//     static <A, B, C> F2<A, B, C> uncurry(@Nonnull final F<A, F<B, C>> f) {
//         return (a, b) -> f.apply(a).apply(b);
//     }
// 
//     @Nonnull
//     static <A, B, C> F<B, F<A, C>> flip(@Nonnull final F<A, F<B, C>> f) {
//         return b -> a -> f.apply(a).apply(b);
//     }
// 
//     @Nonnull
//     R apply(@Nonnull A a);
// 
//     @Nonnull
//     default <C> F<C, R> compose(@Nonnull final F<C, A> f) {
//         return c -> this.apply(f.apply(c));
//     }
// 
// 
//     @Nonnull
//     default <B> F<A, B> then(@Nonnull final F<R, B> f) {
//         return c -> f.apply(this.apply(c));
//     }
// }
// 
// Path: src/main/java/com/shapesecurity/functional/ThrowingSupplier.java
// @FunctionalInterface
// public interface ThrowingSupplier<A> {
//     A get() throws Exception;
// }


// Path: src/main/java/com/shapesecurity/functional/data/Either.java
import com.shapesecurity.functional.Effect;
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.ThrowingSupplier;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;

/*
 * Copyright 2014 Shape Security, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shapesecurity.functional.data;



@CheckReturnValue
public final class Either<A, B> {
    private final Object data;

    private enum Tag {
        LEFT, RIGHT
    }

    private final Tag tag;

    // class local
    private Either(Object data, Tag tag) {
        super();
        this.data = data;
        this.tag = tag;
    }

    @Nonnull
    public static <A, B> Either<A, B> left(@Nonnull A a) {
        return new Either<>(a, Tag.LEFT);
    }

    @Nonnull
    public static <A, B> Either<A, B> right(@Nonnull B b) {
        return new Either<>(b, Tag.RIGHT);
    }

    @Nonnull
    public static <A, B extends A, C extends A> A extract(Either<B, C> e) {
        return e.either(x -> x, x -> x);
    }

    @Nonnull
    public static <A> Either<Exception, A> _try(@Nonnull ThrowingSupplier<A> s) {