Last active
December 11, 2015 03:38
-
-
Save larsrh/4538920 to your computer and use it in GitHub Desktop.
Spire bindings for Scalaz? Or are they Scalaz bindings for Spire?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalaz.contrib | |
package spire | |
import _root_.spire.algebra | |
trait MonoidOps[F] extends SemigroupOps[F] { | |
def asSpire: algebra.Monoid[F] | |
def asScalaz: scalaz.Monoid[F] | |
} | |
private[scalaz] trait SpireMonoidOps[F] extends MonoidOps[F] with SpireSemigroupOps[F] { | |
override def asScalaz: scalaz.Monoid[F] = new ScalazMonoid {} | |
private[scalaz] trait ScalazMonoid extends scalaz.Monoid[F] with ScalazSemigroup { | |
def zero = asSpire.id | |
} | |
} | |
private[scalaz] trait ScalazMonoidOps[F] extends MonoidOps[F] with ScalazSemigroupOps[F] { | |
override def asSpire: algebra.Monoid[F] = new SpireMonoid {} | |
private[scalaz] trait SpireMonoid extends algebra.Monoid[F] with SpireSemigroup { | |
def id = asScalaz.zero | |
} | |
} | |
// vim: expandtab:ts=2:sw=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalaz.contrib | |
package spire | |
import _root_.spire.algebra | |
private[scalaz] trait Ops0 { | |
implicit class SpireSemigroup2Scalaz[F](val asSpire: algebra.Semigroup[F]) extends SpireSemigroupOps[F] | |
implicit class ScalazSemigroup2Spire[F](val asScalaz: scalaz.Semigroup[F]) extends ScalazSemigroupOps[F] | |
} | |
private[scalaz] trait Ops extends Ops0 { | |
implicit class SpireMonoid2Scalaz[F](val asSpire: algebra.Monoid[F]) extends SpireMonoidOps[F] | |
implicit class ScalazMonoid2Spire[F](val asScalaz: scalaz.Monoid[F]) extends ScalazMonoidOps[F] | |
} | |
// vim: expandtab:ts=2:sw=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalaz.contrib | |
import _root_.spire.algebra | |
package object spire extends Ops | |
// vim: expandtab:ts=2:sw=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalaz.contrib | |
package spire | |
import _root_.spire.algebra | |
trait SemigroupOps[F] { | |
def asSpire: algebra.Semigroup[F] | |
def asScalaz: scalaz.Semigroup[F] | |
} | |
private[scalaz] trait SpireSemigroupOps[F] extends SemigroupOps[F] { | |
override def asScalaz: scalaz.Semigroup[F] = new ScalazSemigroup {} | |
private[scalaz] trait ScalazSemigroup extends scalaz.Semigroup[F] { | |
def append(f1: F, f2: => F) = asSpire.op(f1, f2) | |
} | |
} | |
private[scalaz] trait ScalazSemigroupOps[F] extends SemigroupOps[F] { | |
override def asSpire: algebra.Semigroup[F] = new SpireSemigroup {} | |
private[scalaz] trait SpireSemigroup extends algebra.Semigroup[F] { | |
def op(x: F, y: F) = asScalaz.append(x, y) | |
} | |
} | |
// vim: expandtab:ts=2:sw=2package scalaz.contrib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment