Last active
June 18, 2019 14:33
-
-
Save manojo/357553e83485123163d37778f5a37dc2 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 Nats { | |
//we define natural numbers | |
//using peano numbers | |
//inspired from shapeless and https://gist.github.com/jto/2dc882c455b79378289f | |
trait Nat | |
case object Z extends Nat | |
case class Succ[N <: Nat](n: N) extends Nat | |
//shorthand for 1 | |
type One = Succ[Z.type] | |
//Equality of Peano numbers | |
trait Eq[M <: Nat, N <: Nat] | |
delegate eq0 for Eq[Z.type, Z.type] | |
//delegate N for Eq[N, N] { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment