, Huw , downcasting asInstanceOf. , , , - , . , asInstanceOf . asInstanceOf , downcasting .
: , Scalaz , pull request by Huw . , Scalaz - ADT, .. .
ADT (, Haskell OCaml, ), ADT ADT, Scala messy, :
scala> List(1, 2, 3).foldLeft(None)((_, i) => Some(i))
<console>:14: error: type mismatch;
found : Some[Int]
required: None.type
List(1, 2, 3).foldLeft(None)((_, i) => Some(i))
^
foldLeft, None.type, . ( foldLeft), .
Scalaz , ADT, ADT. , none[A] some[A](a: A) Option, Option[A].
( . ).
, :
val thing1: MyThing = Thing1
val thing2: MyThing = Thing2
thing1.node(thing2.leaf). , Argonaut Json ADT ADT-, .