Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize use of implicit parameters #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions core/src/decrel/Relation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,57 +68,43 @@ object Relation {
](
left: LeftTree & Relation[LeftIn, LeftOut],
right: RightTree & Relation[RightIn, RightOut]
)(implicit
zippedEv: LeftIn <:< RightIn
) extends Composed[LeftTree, LeftIn, LeftOut, RightTree, RightIn, RightOut, ZippedOut]

case class Single[
LeftTree,
LeftTree <: Relation.Single[LeftIn, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut
](
left: LeftTree,
right: RightTree
)(implicit
composeOneEv: LeftOut <:< RightIn,
leftRel: LeftTree <:< Relation.Single[LeftIn, LeftOut],
rightRel: RightTree <:< Relation[RightIn, RightOut]
) extends Composed[LeftTree, LeftIn, LeftOut, RightTree, RightIn, RightOut, RightOut]

case class Optional[
LeftTree,
LeftTree <: Relation.Optional[LeftIn, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut
](
left: LeftTree,
right: RightTree
)(implicit
composeOneEv: LeftOut <:< RightIn,
leftRel: LeftTree <:< Relation.Optional[LeftIn, LeftOut],
rightRel: RightTree <:< Relation[RightIn, RightOut]
) extends Composed[LeftTree, LeftIn, LeftOut, RightTree, RightIn, RightOut, Option[RightOut]]

case class Many[
LeftTree,
LeftTree <: Relation.Many[LeftIn, CC, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut,
CC[+A]
](
left: LeftTree,
right: RightTree
)(implicit
composeOneEv: LeftOut <:< RightIn,
leftRel: LeftTree <:< Relation.Many[LeftIn, CC, LeftOut],
rightRel: RightTree <:< Relation[RightIn, RightOut]
) extends Composed[LeftTree, LeftIn, LeftOut, RightTree, RightIn, RightOut, CC[RightOut]]
}
}
26 changes: 11 additions & 15 deletions core/src/decrel/reify/bifunctor/proof.scala
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,14 @@ trait proof { this: access & reifiedRelation =>
LeftTree <: Relation.Single[LeftIn, LeftOut],
LeftIn,
LeftE <: RightE,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightE,
RightOut
](implicit
leftProof: Proof.GenericSingle[LeftTree, LeftIn, LeftE, LeftOut],
rightProof: Proof[RightTree, RightIn, RightE, RightOut],
ev: LeftOut <:< RightIn
rightProof: Proof[RightTree, RightIn, RightE, RightOut]
): Proof.Single[
Relation.Composed.Single[
LeftTree,
Expand Down Expand Up @@ -330,15 +329,14 @@ trait proof { this: access & reifiedRelation =>
LeftTree <: Relation.Optional[LeftIn, LeftOut],
LeftIn,
LeftE <: RightE,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightE,
RightOut
](implicit
leftProof: Proof.Optional[LeftTree, LeftIn, LeftE, LeftOut],
rightProof: Proof[RightTree, RightIn, RightE, RightOut],
ev: LeftOut <:< RightIn
rightProof: Proof[RightTree, RightIn, RightE, RightOut]
): Proof[
Relation.Composed.Optional[
LeftTree,
Expand All @@ -365,16 +363,15 @@ trait proof { this: access & reifiedRelation =>
LeftTree <: Relation.Many[LeftIn, CC, LeftOut],
LeftIn,
LeftE <: RightE,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightE,
RightOut,
CC[+A] <: Iterable[A] & IterableOps[A, CC, CC[A]]
](implicit
leftProof: Proof.Many[LeftTree, LeftIn, LeftE, CC, LeftOut],
rightProof: Proof[RightTree, RightIn, RightE, RightOut],
ev: LeftOut <:< RightIn,
bf: BuildFrom[CC[RightIn], RightOut, CC[RightOut]]
): Proof[
Relation.Composed.Many[
Expand All @@ -401,12 +398,12 @@ trait proof { this: access & reifiedRelation =>

implicit def composedZippedProof[
LeftTree,
LeftIn,
LeftIn <: RightIn,
LeftE <: RightE,
LeftOut,
LeftOutRefined <: LeftOut,
RightTree,
RightIn <: LeftIn,
RightIn,
RightE,
RightOut,
ZippedOut,
Expand All @@ -424,8 +421,7 @@ trait proof { this: access & reifiedRelation =>
RightE,
RightOut
],
zippable: Zippable.Out[LeftOutRefined, RightOut, ZOR],
zippedEv: LeftIn <:< RightIn
zippable: Zippable.Out[LeftOutRefined, RightOut, ZOR]
): Proof[
Relation.Composed.Zipped[
LeftTree,
Expand Down
6 changes: 2 additions & 4 deletions core/src/decrel/reify/bifunctor/reifiedRelation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ trait reifiedRelation { this: access =>
left: ReifiedRelation[LeftIn, LeftE, LeftOut],
right: ReifiedRelation[RightIn, RightE, RightOut]
)(implicit
ev: LeftOut <:< RightIn,
e: LeftE <:< RightE
ev: LeftOut <:< RightIn
) extends ReifiedRelation[LeftIn, RightE, RightOut] {

override def apply(in: LeftIn): Access[RightE, RightOut] =
Expand Down Expand Up @@ -115,8 +114,7 @@ trait reifiedRelation { this: access =>
left: ReifiedRelation[LeftIn, LeftE, Option[LeftOut]],
right: ReifiedRelation[RightIn, RightE, RightOut]
)(implicit
ev: LeftOut <:< RightIn,
e: LeftE <:< RightE
ev: LeftOut <:< RightIn
) extends ReifiedRelation[LeftIn, RightE, Option[RightOut]] {

override def apply(in: LeftIn): Access[RightE, Option[RightOut]] =
Expand Down
26 changes: 11 additions & 15 deletions core/src/decrel/reify/monofunctor/proof.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,13 @@ trait proof { this: access & reifiedRelation =>
implicit def composedSingleProof[
LeftTree <: Relation.Single[LeftIn, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut
](implicit
leftProof: Proof.GenericSingle[LeftTree, LeftIn, LeftOut],
rightProof: Proof[RightTree, RightIn, RightOut],
ev: LeftOut <:< RightIn
rightProof: Proof[RightTree, RightIn, RightOut]
): Proof.Single[
Relation.Composed.Single[
LeftTree,
Expand Down Expand Up @@ -322,14 +321,13 @@ trait proof { this: access & reifiedRelation =>
implicit def composedOptionalProof[
LeftTree <: Relation.Optional[LeftIn, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut
](implicit
leftProof: Proof.Optional[LeftTree, LeftIn, LeftOut],
rightProof: Proof[RightTree, RightIn, RightOut],
ev: LeftOut <:< RightIn
rightProof: Proof[RightTree, RightIn, RightOut]
): Proof[
Relation.Composed.Optional[
LeftTree,
Expand All @@ -353,15 +351,14 @@ trait proof { this: access & reifiedRelation =>
implicit def composedManyProof[
LeftTree <: Relation.Many[LeftIn, CC, LeftOut],
LeftIn,
LeftOut,
RightTree,
LeftOut <: RightIn,
RightTree <: Relation[RightIn, RightOut],
RightIn,
RightOut,
CC[+A] <: Iterable[A] & IterableOps[A, CC, CC[A]]
](implicit
leftProof: Proof.Many[LeftTree, LeftIn, CC, LeftOut],
rightProof: Proof[RightTree, RightIn, RightOut],
ev: LeftOut <:< RightIn,
bf: BuildFrom[CC[RightIn], RightOut, CC[RightOut]]
): Proof[
Relation.Composed.Many[
Expand All @@ -386,11 +383,11 @@ trait proof { this: access & reifiedRelation =>

implicit def composedZippedProof[
LeftTree,
LeftIn,
LeftIn <: RightIn,
LeftOut,
LeftOutRefined <: LeftOut,
RightTree,
RightIn <: LeftIn,
RightIn,
RightOut,
ZippedOut,
ZOR <: ZippedOut
Expand All @@ -405,8 +402,7 @@ trait proof { this: access & reifiedRelation =>
RightIn,
RightOut
],
zippable: Zippable.Out[LeftOutRefined, RightOut, ZOR],
zippedEv: LeftIn <:< RightIn
zippable: Zippable.Out[LeftOutRefined, RightOut, ZOR]
): Proof[
Relation.Composed.Zipped[
LeftTree,
Expand Down
31 changes: 10 additions & 21 deletions core/src/decrel/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ trait syntax {
private val right: RightTree & Relation[RightIn, RightOut]
) {

def >>:[LeftTree, LeftIn, LeftOut](
def >>:[LeftTree, LeftIn, LeftOut <: RightIn](
left: LeftTree & Relation.Single[LeftIn, LeftOut]
)(implicit
ev: LeftOut <:< RightIn
): Relation.Composed.Single[
LeftTree & Relation.Single[LeftIn, LeftOut],
LeftIn,
Expand All @@ -29,10 +27,9 @@ trait syntax {
RightOut
] = Relation.Composed.Single(left, right)

def <>:[LeftTree, LeftIn, LeftOut, ZippedOut](
def <>:[LeftTree, LeftIn, LeftOut <: RightIn, ZippedOut](
left: LeftTree & Relation.Single[LeftIn, LeftOut]
)(implicit
ev: LeftOut <:< RightIn,
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut]
): Relation.Composed.Zipped[
LeftTree & Relation.Single[LeftIn, LeftOut],
Expand All @@ -52,10 +49,8 @@ trait syntax {
] =
Relation.Composed.Zipped(left, Relation.Composed.Single(left, right))

def >>:[LeftTree, LeftIn, LeftOut](
def >>:[LeftTree, LeftIn, LeftOut <: RightIn](
left: LeftTree & Relation.Optional[LeftIn, LeftOut]
)(implicit
ev: LeftOut <:< RightIn
): Relation.Composed.Optional[
LeftTree & Relation.Optional[LeftIn, LeftOut],
LeftIn,
Expand All @@ -65,10 +60,9 @@ trait syntax {
RightOut
] = Relation.Composed.Optional(left, right)

def <>:[LeftTree, LeftIn, LeftOut, ZippedOut](
def <>:[LeftTree, LeftIn, LeftOut <: RightIn, ZippedOut](
left: LeftTree & Relation.Optional[LeftIn, LeftOut]
)(implicit
ev: LeftOut <:< RightIn,
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut]
): Composed.Optional[
LeftTree & Relation.Optional[LeftIn, LeftOut],
Expand All @@ -88,10 +82,8 @@ trait syntax {
] =
Relation.Composed.Optional(left, Relation.Composed.Zipped(Relation.Self[LeftOut], right))

def >>:[LeftTree, LeftIn, LeftOut, CC[+A]](
def >>:[LeftTree, LeftIn, LeftOut <: RightIn, CC[+A]](
left: LeftTree & Relation.Many[LeftIn, CC, LeftOut]
)(implicit
ev: LeftOut <:< RightIn
): Relation.Composed.Many[
LeftTree & Relation.Many[LeftIn, CC, LeftOut],
LeftIn,
Expand All @@ -102,10 +94,9 @@ trait syntax {
CC
] = Relation.Composed.Many(left, right)

def <>:[LeftTree, LeftIn, LeftOutO, ZippedOut, CC[+A]](
def <>:[LeftTree, LeftIn, LeftOutO <: RightIn, ZippedOut, CC[+A]](
left: LeftTree & Relation.Many[LeftIn, CC, LeftOutO]
)(implicit
ev: LeftOutO <:< RightIn,
zippable: Zippable.Out[LeftOutO, RightOut, ZippedOut]
): Composed.Many[
LeftTree & Relation.Many[LeftIn, CC, LeftOutO],
Expand Down Expand Up @@ -137,14 +128,13 @@ trait syntax {
*/
def zip[
RightTree,
RightIn,
RightIn >: LeftIn,
RightOut,
ZippedOut
](
that: RightTree & Relation[RightIn, RightOut]
)(implicit
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut],
ev: LeftIn <:< RightIn
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut]
): Relation.Composed.Zipped[
LeftTree & Relation[LeftIn, LeftOut],
LeftIn,
Expand All @@ -161,14 +151,13 @@ trait syntax {
*/
def &[
RightTree,
RightIn <: LeftIn,
RightIn >: LeftIn,
RightOut,
ZippedOut
](
that: RightTree & Relation[RightIn, RightOut]
)(implicit
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut],
ev: LeftIn <:< RightIn
zippable: Zippable.Out[LeftOut, RightOut, ZippedOut]
): Relation.Composed.Zipped[
LeftTree & Relation[LeftIn, LeftOut],
LeftIn,
Expand Down