Skip to content

Instantly share code, notes, and snippets.

View tjheslin1's full-sized avatar

Thomas Heslin tjheslin1

  • London
View GitHub Profile

Taken from Essential Scala by Noel Welsh and Dave Gurnell

Invariant: Foo[T]: Foo[A] and Foo[B] are unrelated regardless of the relationship between A and B

Covariant: Foo[+T] -> Foo[A] is a supertype ofFoo[B] if A is a supertype of B.

Contravariant: Foo[-T] -> Foo[A] is a subtype of Foo[B] if A is a supertype of B.

Example:

sealed trait Node {
def print: String =
this match {
case Obj(v) => v.toString
case JSONObj(v) => s"{\n${v.print}\n}"
case Element(k, v) => s"""\t"$k": "${v.print}",\n"""
case JSONEnd => ""
case JSONPair(hd, tl) => s"${hd.print} ${tl.print}"
case JSONSeq(hd, tl) => s"[ ${hd.print} ${tl.print} ]"
}
httpPort: 7000
cacheDuration: 60
probeConnectionWaitInSeconds: 10
databases:
- name: bobsDatabase
user: system
jdbcUrl: jdbc:oracle:thin:@localhost:1522:xe
probes:
- healthCheck
- noLabels