|
Scala example source code file (InvariantFunctorTest.scala)
The InvariantFunctorTest.scala Scala example source codepackage scalaz import BijectionT.{Bijection, liftBijection} import Id.Id import Isomorphism.{<=>, IsoSet} import std.AllInstances._ import std.option.some import syntax.invariantFunctor._ object InvariantFunctorTest extends SpecLite { "xmap" in { some(1).xmap[Int](_ + 1, _ - 1) must_===(some(2)) } "xmap iso" in { val succI: Int <=> Int = new IsoSet[Int, Int] { def to = (_: Int) + 1 def from = (_: Int) - 1 } some(1) xmapi succI must_===(some(2)) } "xmap bijection" in { val succB: Bijection[Int, Int] = liftBijection[Id, Id, Int, Int](_ + 1, _ - 1) some(1) xmapb succB must_===(some(2)) } case class Num(x: Int) implicit val showNum = Show.showA[Num] implicit val eqNum = Equal.equalA[Num] } Other Scala examples (source code examples)Here is a short list of links related to this Scala InvariantFunctorTest.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.