disjoint union - Scala variable parameter count Either -


is there implemented variable parameter count scala either in library, mean analogic hlist. don't want implement myself :-)

this not directly answer question have considered using scalaz's either type symbol \/ ? can "chain" several types in sum type, this:

import scalaz._  lazy val a: int \/ string = ??? // a: scalaz.\/[int,string] = <lazy>  lazy val b: int \/ string \/ double = ??? // b: scalaz.\/[scalaz.\/[int,string],double] = <lazy>  lazy val c: int \/ string \/ double \/ bigint = ??? // c: scalaz.\/[scalaz.\/[scalaz.\/[int,string],double],bigint] = <lazy>    val d1: int \/ string \/ double \/ bigint = -\/(\/-(42d)) // d1: scalaz.\/[scalaz.\/[scalaz.\/[int,string],double],bigint] = -\/(\/-(42d))  import scalaz._  val d2: int \/ string \/ double \/ bigint = 42d.right.left // d2: scalaz.\/[scalaz.\/[scalaz.\/[int,string],double],bigint] = -\/(\/-(42d))    val e1: int \/ string \/ double \/ bigint = -\/(-\/(\/-("42"))) // e1: scalaz.\/[scalaz.\/[scalaz.\/[int,string],double],bigint] = -\/(-\/(\/-("42")))  import scalaz._  val e2: int \/ string \/ double \/ bigint = "42".right.left.left // e2: scalaz.\/[scalaz.\/[scalaz.\/[int,string],double],bigint] = -\/(-\/(\/-("42"))) 

it has extractors can pattern match these things.

but if have involved types under control, rolling own algebraic data type (as outlined in travis brown's comment above) better solution.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -