|
Scala example source code file (ConstTest.scala)
The ConstTest.scala Scala example source code
package scalaz
import std.AllInstances._
import scalaz.scalacheck.ScalazProperties._
import scalaz.scalacheck.ScalazArbitrary._
import Const._
import org.scalacheck.Prop.forAll
object ConstTest extends SpecLite {
checkAll("Const", order.laws[Const[Int, String]])
checkAll("Const List" , applicative.laws[λ[α => Const[List[Int], α]]])
checkAll("Const Option", applicative.laws[λ[α => Const[Option[Int], α]]])
checkAll(traverse.laws[Const[Int, ?]])
checkAll(contravariant.laws[Const[Int, ?]])
"const functions" in {
"const" ! forAll { (x: Int, y: Function0[String]) =>
const(x)(y) == x
}
}
object instances {
def functor[C] = Functor[Const[C, ?]]
def traverse[C] = Traverse[Const[C, ?]]
def functorMax[C: Monoid] = Functor[Const[C, ?]]
def apply[C: Semigroup] = Apply[Const[C, ?]]
def applicative[C: Monoid] = Applicative[Const[C, ?]]
def equal[C: Equal, A] = Equal[Const[C, A]]
def equalMax[C: Order, A] = Equal[Const[C, A]]
def order[C: Order, A] = Order[Const[C, A]]
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala ConstTest.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.