Coproduct also supports mapping given a polymorphic function such as
Coproduct also supports mapping given a polymorphic function such as
object sizeM extends Poly1 { implicit def caseInt = at[Int](i => (i, i)) implicit def caseString = at[String](s => (s, s.length)) implicit def caseBoolean = at[Boolean](b => (b, 1)) }
type ISB = Int :+: String :+: Boolean :+: CNil val isb = Coproduct[ISB]("foo")
In the same way that adding labels To the elements of an HList gives us a record, adding labels to the elements of a Coproduct gives us a discriminated union.
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
Please use 'an [Exception] should be thrownBy { ... }' syntax instead
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
Coproducts and discriminated unions
shapeless has a Coproduct type, a generalization of Scala's
Either
to an arbitrary number of choices. Currently it exists primarily to supportGeneric
(see the next section), but will be expanded analogously toHList
in later releases. CurrentlyCoproduct
supports mapping, selection and unification