|
Scala example source code file (Compose.scala)
The Compose.scala Scala example source codepackage scalaz //// /** * */ //// trait Compose[=>:[_, _]] { self => //// /** Associative `=>:` binary operator. */ def compose[A, B, C](f: B =>: C, g: A =>: B): (A =>: C) protected[this] trait ComposePlus extends Plus[λ[α => α =>: α]] { def plus[A](f1: (A =>: A), f2: => (A =>: A)) = self.compose(f1, f2) } protected[this] trait ComposeSemigroup[A] extends Semigroup[A =>: A] { def append(f1: (A =>: A), f2: => (A =>: A)) = self.compose(f1, f2) } /** `semigroup`, but universally quantified. */ def plus: Plus[λ[α => α =>: α]] = new ComposePlus {} /** The endomorphism semigroup, where `append`=`compose`. */ def semigroup[A]: Semigroup[A =>: A] = new ComposeSemigroup[A] {} trait ComposeLaw { /** `compose` is associative. */ def associative[A, B, C, D](ab: (A =>: B), bc: (B =>: C), cd: (C =>: D)) (implicit E: Equal[A =>: D]): Boolean = { val ad1 = compose(cd, compose(bc, ab)) val ad2 = compose(compose(cd, bc), ab) E.equal(ad1, ad2) } } def composeLaw = new ComposeLaw {} //// val composeSyntax = new scalaz.syntax.ComposeSyntax[=>:] { def F = Compose.this } } object Compose { @inline def apply[F[_, _]](implicit F: Compose[F]): Compose[F] = F //// //// } Other Scala examples (source code examples)Here is a short list of links related to this Scala Compose.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.