/** * Use an existing instance of a type that implements Unit to create a KleisliM arrow for that type * * <pre> * {@code * Seq<Integer> myList = Seq.of(1,2,3); Fn1<? super String, ? extends Seq<String>> arrow = Functions.arrowUnit(myList); Seq<String> list = arrow.applyHKT("hello world"); * * } * </pre> * * @param w * @param <T> * @param <W> * @return */ public static final <T,W extends Unit<T>> Function1<? super T,? extends W> arrowUnit(Unit<?> w){ return t-> (W)w.unit(t); }
/** * Use an existing instance of a type that implements Unit to create a KleisliM arrow for that type * * <pre> * {@code * Seq<Integer> myList = Seq.of(1,2,3); Fn1<? super String, ? extends Seq<String>> arrow = Functions.arrowUnit(myList); Seq<String> list = arrow.applyHKT("hello world"); * * } * </pre> * * @param w * @param <T> * @param <W> * @return */ public static final <T,W extends Unit<T>> Function1<? super T,? extends W> arrowUnit(Unit<?> w){ return t-> (W)w.unit(t); }