Skip to content

Instantly share code, notes, and snippets.

@manojo
Last active June 18, 2019 14:33
Show Gist options
  • Save manojo/357553e83485123163d37778f5a37dc2 to your computer and use it in GitHub Desktop.
Save manojo/357553e83485123163d37778f5a37dc2 to your computer and use it in GitHub Desktop.
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