<commit_before>package com.aol.cyclops.control;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import com.aol.cyclops.Matchables;
import com.aol.cyclops.Reducer;
import com.aol.cyclops.Semigroup;
import com.aol.cyclops.data.collections.extensions.CollectionX;
import com.aol.cyclops.data.collections.extensions.standard.ListX;
import com.aol.cyclops.types.ConvertableFunctor;
import com.aol.cyclops.types.Filterable;
import com.aol.cyclops.types.MonadicValue;
import com.aol.cyclops.types.applicative.Applicativable;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;


/**
 * Totally lazy more powerful general Option type
 * 
 * @author johnmcclean
 *
 * @param <T>
 */
public interface Maybe<T> extends MonadicValue<T>,
								Supplier<T>, 
								ConvertableFunctor<T>, 
								Filterable<T>,
								Applicativable<T>,
								Matchable.ValueAndOptionalMatcher<T>
								{

	
	final static Maybe EMPTY = new Nothing<>();
	
	static <T> Maybe<T> none(){
		return  EMPTY;
	}
	
	static <T> Maybe<T> fromOptional(Optional<T> opt){
		if(opt.isPresent())
			return Maybe.of(opt.get());
		return none();
	}
	
	static <T> Maybe<T> fromEvalOf(Eval<T> eval){
		return new Just<T>(eval);
	}
	static <T> Maybe<T> just(T value){
	    return of(value);
	}
	static <T> Maybe<T> of(T value){
		Objects.requireNonNull(value);
		return new Just<T>(Eval.later(()->value));<commit_msg>AnyM support for monad transformers<commit_after>package com.aol.cyclops.control;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import com.aol.cyclops.Matchables;
import com.aol.cyclops.Reducer;
import com.aol.cyclops.Semigroup;
import com.aol.cyclops.data.collections.extensions.CollectionX;
import com.aol.cyclops.data.collections.extensions.standard.ListX;
import com.aol.cyclops.types.ConvertableFunctor;
import com.aol.cyclops.types.Filterable;
import com.aol.cyclops.types.MonadicValue;
import com.aol.cyclops.types.applicative.Applicativable;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;


/**
 * Totally lazy more powerful general Option type
 * 
 * @author johnmcclean
 *
 * @param <T>
 */
public interface Maybe<T> extends MonadicValue<T>,
								Supplier<T>, 
								ConvertableFunctor<T>, 
								Filterable<T>,
								Applicativable<T>,
								Matchable.ValueAndOptionalMatcher<T>,
								MaybeOps<T>
								{

   
	
	final static Maybe EMPTY = new Nothing<>();
	
	static <T> Maybe<T> none(){
		return  EMPTY;
	}
	
	static <T> Maybe<T> fromOptional(Optional<T> opt){
		if(opt.isPresent())
			return Maybe.of(opt.get());
		return none();
	}
	
	static <T> Maybe<T> fromEvalOf(Eval<T> eval){
		return new Just<T>(eval);
	}
	static <T> Maybe<T> just(T value){
	    return of(value);
	}
	static <T> Maybe<T> of(T value){
		Objects.requireNonNull(value);
		return new Just<T>(Eval.later(()->value));
{'fraction_non_alphanumeric': 0.13232938160845883, 'fraction_numerical': 0.0, 'mean_word_length': 4.291525423728814, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7242421', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1069, 'n_words': 210}