All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.purefun.instances.ScheduleInstances Maven / Gradle / Ivy

package com.github.tonivade.purefun.instances;

import static com.github.tonivade.purefun.typeclasses.ScheduleOf.toSchedule;
import com.github.tonivade.purefun.Function1;
import com.github.tonivade.purefun.Kind;
import com.github.tonivade.purefun.Witness;
import com.github.tonivade.purefun.typeclasses.Functor;
import com.github.tonivade.purefun.typeclasses.Profunctor;
import com.github.tonivade.purefun.typeclasses.Schedule;
import com.github.tonivade.purefun.typeclasses.Schedule_;

@SuppressWarnings("unchecked")
public interface ScheduleInstances {
  
  static  Functor, A>> functor() {
    return ScheduleFunctor.INSTANCE;
  }
  
  static  Profunctor> profunctor() {
    return ScheduleProfunctor.INSTANCE;
  }
}

interface ScheduleFunctor extends Functor, A>> {
   
  @SuppressWarnings("rawtypes")
  ScheduleFunctor INSTANCE = new ScheduleFunctor() {};
  
  @Override
  default  Schedule map(
      Kind, A>, ? extends T> value, 
      Function1 mapper) {
    return value.fix(toSchedule()).map(mapper);
  }
}

interface ScheduleProfunctor extends Profunctor> {

  @SuppressWarnings("rawtypes")
  ScheduleProfunctor INSTANCE = new ScheduleProfunctor() {};
  
  @Override
  default  Schedule dimap(
      Kind, A>, ? extends B> value, 
      Function1 contramap, 
      Function1 map) {
    return value.fix(toSchedule()).dimap(contramap, map);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy