summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-03-20 19:21:42 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-03-20 19:21:42 -0400
commit9ace8e5bcce74808ab0a33115017bcf200e03a96 (patch)
tree915b576d4b3aad087eaa24be6452eb491f7b8532 /BJC-Utils2/src/main/java/bjc/utils
parent6b659fe44d6d1d3381a4404c1b8685763f40f344 (diff)
Update
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java194
1 files changed, 97 insertions, 97 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java
index d6da637..8e9bbd2 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java
@@ -1,97 +1,97 @@
-package bjc.utils.funcdata.theory;
-
-import java.util.function.Function;
-
-/**
- * A functor over a pair of heterogenous types
- *
- * @author ben
- * @param <LeftType>
- * The type stored on the 'left' of the pair
- * @param <RightType>
- * The type stored on the 'right' of the pair
- *
- */
-public interface Bifunctor<LeftType, RightType> {
- /**
- * Lift a pair of functions to a single function that maps over both
- * parts of a pair
- *
- * @param <OldLeft>
- * The old left type of the pair
- * @param <OldRight>
- * The old right type of the pair
- * @param <NewLeft>
- * The new left type of the pair
- * @param <NewRight>
- * The new right type of the pair
- * @param leftFunc
- * The function that maps over the left of the pair
- * @param rightFunc
- * The function that maps over the right of the pair
- * @return A function that maps over both parts of the pair
- */
- public default <OldLeft, OldRight, NewLeft, NewRight> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, NewRight>> bimap(
- Function<OldLeft, NewLeft> leftFunc, Function<OldRight, NewRight> rightFunc) {
- Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, NewRight>> bimappedFunc = (argPair) -> {
- Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, OldRight>> leftMapper = argPair
- .<OldLeft, OldRight, NewLeft>fmapLeft(leftFunc);
-
- Bifunctor<NewLeft, OldRight> leftMappedFunctor = leftMapper.apply(argPair);
- Function<Bifunctor<NewLeft, OldRight>, Bifunctor<NewLeft, NewRight>> rightMapper = leftMappedFunctor
- .<NewLeft, OldRight, NewRight>fmapRight(rightFunc);
-
- return rightMapper.apply(leftMappedFunctor);
- };
-
- return bimappedFunc;
- }
-
- /**
- * Lift a function to operate over the left part of this pair
- *
- * @param <OldLeft>
- * The old left type of the pair
- * @param <OldRight>
- * The old right type of the pair
- * @param <NewLeft>
- * The new left type of the pair
- * @param func
- * The function to lift to work over the left side of the
- * pair
- * @return The function lifted to work over the left side of bifunctors
- */
- public <OldLeft, OldRight, NewLeft> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, OldRight>> fmapLeft(
- Function<OldLeft, NewLeft> func);
-
- /**
- * Lift a function to operate over the right part of this pair
- *
- * @param <OldLeft>
- * The old left type of the pair
- * @param <OldRight>
- * The old right type of the pair
- * @param <NewRight>
- * The new right type of the pair
- * @param func
- * The function to lift to work over the right side of
- * the pair
- * @return The function lifted to work over the right side of bifunctors
- */
- public <OldLeft, OldRight, NewRight> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<OldLeft, NewRight>> fmapRight(
- Function<OldRight, NewRight> func);
-
- /**
- * Get the value contained on the left of this bifunctor
- *
- * @return The value on the left side of this bifunctor
- */
- public LeftType getLeft();
-
- /**
- * Get the value contained on the right of this bifunctor
- *
- * @return The value on the right of this bifunctor
- */
- public RightType getRight();
-}
+package bjc.utils.funcdata.theory;
+
+import java.util.function.Function;
+
+/**
+ * A functor over a pair of heterogeneous types
+ *
+ * @author ben
+ * @param <LeftType>
+ * The type stored on the 'left' of the pair
+ * @param <RightType>
+ * The type stored on the 'right' of the pair
+ *
+ */
+public interface Bifunctor<LeftType, RightType> {
+ /**
+ * Lift a pair of functions to a single function that maps over both
+ * parts of a pair
+ *
+ * @param <OldLeft>
+ * The old left type of the pair
+ * @param <OldRight>
+ * The old right type of the pair
+ * @param <NewLeft>
+ * The new left type of the pair
+ * @param <NewRight>
+ * The new right type of the pair
+ * @param leftFunc
+ * The function that maps over the left of the pair
+ * @param rightFunc
+ * The function that maps over the right of the pair
+ * @return A function that maps over both parts of the pair
+ */
+ public default <OldLeft, OldRight, NewLeft, NewRight> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, NewRight>> bimap(
+ Function<OldLeft, NewLeft> leftFunc, Function<OldRight, NewRight> rightFunc) {
+ Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, NewRight>> bimappedFunc = (argPair) -> {
+ Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, OldRight>> leftMapper = argPair
+ .<OldLeft, OldRight, NewLeft>fmapLeft(leftFunc);
+
+ Bifunctor<NewLeft, OldRight> leftMappedFunctor = leftMapper.apply(argPair);
+ Function<Bifunctor<NewLeft, OldRight>, Bifunctor<NewLeft, NewRight>> rightMapper = leftMappedFunctor
+ .<NewLeft, OldRight, NewRight>fmapRight(rightFunc);
+
+ return rightMapper.apply(leftMappedFunctor);
+ };
+
+ return bimappedFunc;
+ }
+
+ /**
+ * Lift a function to operate over the left part of this pair
+ *
+ * @param <OldLeft>
+ * The old left type of the pair
+ * @param <OldRight>
+ * The old right type of the pair
+ * @param <NewLeft>
+ * The new left type of the pair
+ * @param func
+ * The function to lift to work over the left side of the
+ * pair
+ * @return The function lifted to work over the left side of bifunctors
+ */
+ public <OldLeft, OldRight, NewLeft> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<NewLeft, OldRight>> fmapLeft(
+ Function<OldLeft, NewLeft> func);
+
+ /**
+ * Lift a function to operate over the right part of this pair
+ *
+ * @param <OldLeft>
+ * The old left type of the pair
+ * @param <OldRight>
+ * The old right type of the pair
+ * @param <NewRight>
+ * The new right type of the pair
+ * @param func
+ * The function to lift to work over the right side of
+ * the pair
+ * @return The function lifted to work over the right side of bifunctors
+ */
+ public <OldLeft, OldRight, NewRight> Function<Bifunctor<OldLeft, OldRight>, Bifunctor<OldLeft, NewRight>> fmapRight(
+ Function<OldRight, NewRight> func);
+
+ /**
+ * Get the value contained on the left of this bifunctor
+ *
+ * @return The value on the left side of this bifunctor
+ */
+ public LeftType getLeft();
+
+ /**
+ * Get the value contained on the right of this bifunctor
+ *
+ * @return The value on the right of this bifunctor
+ */
+ public RightType getRight();
+}