alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (UnapplyTest.scala)

This example Scala source code file (UnapplyTest.scala) is included in the alvinalexander.com "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

applicative, arrow, char, int, kleisli, monad, string, unapply2, unapplyproduct, unapplytest, writer

The UnapplyTest.scala Scala example source code

package scalaz

import Leibniz.===

object UnapplyTest extends SpecLite {
  object unapply {
    val ue = Unapply[Monad, Int \/ String]
    def mequiv[A] = implicitly[ue.M[A] === (Int \/ A)]
    implicitly[ue.A === String]

    // needs only transient stable type
    Unapply[Monad, Int \/ String].TC : Monad[Int \/ ?]
  }

  object unapply2 {
    val ue = Unapply2[Arrow, Kleisli[NonEmptyList, Int, String]]
    def mequiv[A,B] = implicitly[ue.M[A,B] === Kleisli[NonEmptyList, A, B]]
    implicitly[ue.A === Int]
    implicitly[ue.B === String]

    // needs only transient stable type
    Unapply2[Arrow, Kleisli[NonEmptyList, Int, String]].TC: Arrow[Kleisli[NonEmptyList, ?, ?]]
  }

  object unapplyProduct {
    val ue = UnapplyProduct[Applicative, Writer[IList[String], Int], Writer[IList[String], Char]]
    def mequiv[A] = implicitly[ue.M[A] === Writer[IList[String], A]]
    implicitly[ue.A === Int]
    implicitly[ue.B === Char]

    // needs only transient stable type
    UnapplyProduct[Applicative, Writer[IList[String], Int], Writer[IList[String], Char]].TC: Applicative[Writer[IList[String], ?]]
  }
}

Other Scala examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

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.