// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
//     R invoke(T1 arg);
// }
// 
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
//     void invoke(T1 arg);
// }


import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;
package com.github.kmizu.jcombinator;



public interface ParseResult<T> {
	public static class Success<T> implements ParseResult<T> {
		private T value;
		private String next;
		Success(T value, String next) {
			this.value = value;
			this.next = next;
		}
		public T value() {
			return value;
		}
		public String next() {
			return next;
		}
		
		@Override
		public <U> U fold(
		  Function1<Success<T>, U> succ,
		  Function1<Failure<T>, U> fail) {
			return succ.invoke(this);
		}
	
		@Override
		public void fold(
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
//     R invoke(T1 arg);
// }
// 
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
//     void invoke(T1 arg);
// }


// Path: src/main/java/com/github/kmizu/jcombinator/ParseResult.java
import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;

package com.github.kmizu.jcombinator;



public interface ParseResult<T> {
	public static class Success<T> implements ParseResult<T> {
		private T value;
		private String next;
		Success(T value, String next) {
			this.value = value;
			this.next = next;
		}
		public T value() {
			return value;
		}
		public String next() {
			return next;
		}
		
		@Override
		public <U> U fold(
		  Function1<Success<T>, U> succ,
		  Function1<Failure<T>, U> fail) {
			return succ.invoke(this);
		}
	
		@Override
		public void fold(
			Procedure1<Success<T>> succ,