| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (UnwriterTTest.scala)

This example Scala source code file (UnwriterTTest.scala) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Scala by Example" TM.

Learn more about this Scala project at its project page.

Java - Scala tags/keywords

apply, arbitrary, bind, equal, foldable, functor, speclite, traverse, unwriterarb, unwritertopt, unwriterttest

The UnwriterTTest.scala Scala example source code

package scalaz

import scalaz.scalacheck.ScalazProperties._
import scalaz.scalacheck.ScalazArbitrary._
import scalaz.scalacheck.ScalaCheckBinding._
import std.AllInstances._
import org.scalacheck.Arbitrary

object UnwriterTTest extends SpecLite {

  type UnwriterTOpt[W, A] = UnwriterT[Option, W, A]
  type UnwriterTOptInt[A] = UnwriterTOpt[Int, A]


  implicit def UnwriterArb[F[_], W, A](implicit W: Arbitrary[W], A: Arbitrary[A]): Arbitrary[Unwriter[W, A]] =
    Applicative[Arbitrary].apply2(W, A)(Unwriter(_, _))

  checkAll(comonad.laws[Unwriter[Int, ?]])

  object instances {
    def equal[F[_], W, A](implicit E: Equal[F[(W, A)]]) = Equal[UnwriterT[F, W, A]]
    def functor[F[_]: Functor, W] = Functor[UnwriterT[F, W, ?]]
    def apply[F[_]: Apply, W] = Apply[UnwriterT[F, W, ?]]
    def bind[F[_]: Bind, W] = Bind[UnwriterT[F, W, ?]]
    def bifunctor[F[_]: Functor] = Bifunctor[UnwriterT[F, ?, ?]]
    def bitraverse[F[_]: Traverse] = Bitraverse[UnwriterT[F, ?, ?]]
    def foldable[F[_]: Foldable, W] = Foldable[UnwriterT[F, W, ?]]
    def traverse[F[_]: Traverse, W] = Traverse[UnwriterT[F, W, ?]]

    object Unwriter {
      def comonad[W] = Comonad[Unwriter[W, ?]]

Other Scala examples (source code examples)

Here is a short list of links related to this Scala UnwriterTTest.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
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.