Created
September 21, 2014 00:43
-
-
Save shadaj/c7b2a00e1245f603516b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Example { | |
import scala.collection.IndexedSeqLike | |
trait BaseLike | |
class DNABase extends BaseLike | |
trait BioSequence[B <: BaseLike] extends IndexedSeq[B] | |
class DNA extends BioSequence[DNABase] with IndexedSeqLike[DNABase, DNA] { | |
override def newBuilder = ??? | |
def length = 1 | |
def apply(idx: Int) = { | |
new DNABase | |
} | |
} | |
val myDNA = new DNA | |
val droppedDNA: DNA = myDNA.drop(1) // Compiles because DNA extends IndexedSeqLike | |
def processSequence[B <: BaseLike, C <: BioSequence[B]](seq: C): C = { | |
seq.drop(1) // Doesn't compile because BioSequence doesn't extend IndexedSeqLike | |
} | |
} | |
object ScalaJSExample extends js.JSApp { | |
def main() = { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment