Skip to content

Instantly share code, notes, and snippets.

@milessabin
Created March 21, 2016 10:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milessabin/80abc629d3b7deb0ecc4 to your computer and use it in GitHub Desktop.
Save milessabin/80abc629d3b7deb0ecc4 to your computer and use it in GitHub Desktop.
Idris's Dec in Scala
sealed trait Dec[+T]
final case class Yes[T](t: T) extends Dec[T]
final case object No extends Dec[Nothing]
object Dec extends Dec0 {
implicit def yes[T](implicit t: T): Dec[T] = Yes(t)
}
trait Dec0 {
implicit def no[T]: Dec[T] = No
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment