Skip to content

fix: low priority implicits etc #2

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

Merged
merged 1 commit into from
Oct 10, 2016
Merged
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
15 changes: 8 additions & 7 deletions shared/src/main/scala/com/thoughtworks/Extractor.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.thoughtworks

private[thoughtworks] sealed trait LowPrirorityExtractor {

private[thoughtworks] sealed trait LowPriorityExtractor {
sealed trait SeqExtractor[-A, +B] {
def unapplySeq(a: A): Option[Seq[B]]
}

implicit final class OptionFunctionToSeqExtractor[-A, +B] private[LowPrirorityExtractor](underlying: A => Option[Seq[B]]) {
implicit final class OptionFunctionToSeqExtractor[-A, +B] private[LowPriorityExtractor](underlying: A => Option[Seq[B]]) {
def extractSeq = new SeqExtractor[A, B] {
def unapplySeq(a: A) = underlying(a)
}
}

implicit final class OptionFunctionToExtractor[-A, +B] private[LowPrirorityExtractor](underlying: A => Option[B]) {
implicit final class OptionFunctionToExtractor[-A, +B] private[LowPriorityExtractor](underlying: A => Option[B]) {
def extract = new Extractor[A, B] {
def unapply(a: A) = underlying(a)
}
Expand All @@ -27,6 +27,7 @@ sealed trait Extractor[-A, +B] {
def unapply(a: A): Option[B]
}


/**
* Utilities to convert between `A => Option[B]`, `PartialFunction[A, B]` and [[Extractor]].
*
Expand Down Expand Up @@ -64,7 +65,7 @@ sealed trait Extractor[-A, +B] {
}}}
*
*/
object Extractor extends LowPrirorityExtractor {
object Extractor extends LowPriorityExtractor {

implicit final class PartialFunctionToSeqExtractor[-A, +B] private[Extractor](underlying: PartialFunction[A, Seq[B]]) {
def extractSeq = new SeqExtractor[A, B] {
Expand All @@ -84,4 +85,4 @@ object Extractor extends LowPrirorityExtractor {
}
}

}
}