Anyone who has been following Tony Morris' blog and scala exercises, will know that these two type signatures are equivalent:
trait MyOption1[A] {
//this is a catamorphism
def fold[B](some : A => B, none : => B) : B
}
And:
trait MyOption2[A] {
def map[B](f : A => B) : MyOption2[B]
def getOrElse[B >: A](none : => B) : B
}
Furthermore, it has been stated that the type is singly-inhabited (i.e. all implementations of the type are exactly equivalent). I can guess at proving the equivalence of the two types but don't really know where to start on the single-inhabitance statement. How does one prove this?