Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a semigroup for things tagged with Tags.MinVal which selects the minimum val:</p> <pre><code>scala&gt; import scalaz._ ; import Scalaz._ ; import Tags._ import scalaz._ import Scalaz._ import Tags._ scala&gt; MinVal(3).some |+| MinVal(1).some res0: Option[scalaz.@@[Int,scalaz.Tags.MinVal]] = Some(1) scala&gt; MinVal(3).some |+| none[Int @@ MinVal] res1: Option[scalaz.@@[Int,scalaz.Tags.MinVal]] = Some(3) scala&gt; none[Int @@ MinVal] |+| none[Int @@ MinVal] res2: Option[scalaz.@@[Int,scalaz.Tags.MinVal]] = None </code></pre> <p>In the above, <code>Int @@ MinVal</code> is a type which is a subtype of <code>Int</code>, which has been "Tagged" with <code>MinVal</code>, which helps select the right semigroup. <code>MinVal(x: Int)</code> returns x with the type <code>Int @@ MinVal</code>. <code>x.some</code> is like <code>Some(x)</code> except the type is <code>Option</code> instead of <code>Some</code>, and this helps with type inference (there is a Semigroup for Option, but not for Some), similarly <code>none[T]</code> returns <code>None</code>, but its type is <code>Option[T]</code> instead of <code>None</code> (helpful for the same reasons, there is no Semigroup for None, but there is one for Option)</p> <p>If there are more than two, perhaps you have a list of these, you can use <code>suml</code>:</p> <pre><code>scala&gt; List(MinVal(2).some, None, MinVal(3).some, None, MinVal(1).some).suml res5: Option[scalaz.@@[Int,scalaz.Tags.MinVal]] = Some(1) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload