Created
September 4, 2013 12:44
-
-
Save mads-hartmann/6436434 to your computer and use it in GitHub Desktop.
Attempt at implementing `++` for a statically sized list
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 NList { | |
import Nat._ | |
sealed trait NList[L <: Nat, A] { | |
def ++[B >: A, M <: Nat](other: NList[M, B]) | |
(implicit sum: Plus[L, M]): NList[sum.Out, B] | |
} | |
case object NNil extends NList[Zero, Nothing] { | |
/* | |
[error] found : NList.NList[M,B] | |
[error] required: NList.NList[sum.Out,B] | |
[error] (implicit sum: Plus[Zero, M]): NList[sum.Out, B] = other | |
[error] ^ | |
*/ | |
def ++[B >: Nothing, M <: Nat](other: NList[M, B]) | |
(implicit sum: Plus[Zero, M]): NList[sum.Out, B] = other | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment