Skip to content

Commit

Permalink
Updated to latest build; added right to left demo.
Browse files Browse the repository at this point in the history
Miles Sabin committed Apr 18, 2016
1 parent f0283f2 commit ca31b36
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ lazy val commonSettings = Seq(
version := "0.1.0",
resolvers += "scalatl" at "http://milessabin.com/scalatl",
//scalaVersion := "2.11.8" // compile will fail
scalaVersion := "2.11.8-tl-201604151108", // compile succeeds
scalaVersion := "2.11.8-tl-201604181208", // compile succeeds
scalaBinaryVersion := "2.11"
)

29 changes: 29 additions & 0 deletions src/main/scala/si2712fix/demo3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package si2712fix

import scala.annotation.unifyRightToLeft

// Cats Xor, Scalaz \/, scala.util.Either
sealed abstract class Xor[+A, +B] extends Product with Serializable
object Xor {
final case class Left[+A](a: A) extends (A Xor Nothing)
final case class Right[+B](b: B) extends (Nothing Xor B)
}

object TestXor {
import Xor._
def meh[F[_], A, B](fa: F[A])(f: A => B): F[B] = ???
meh(new Right(23): Xor[Boolean, Int])(_ < 13)
meh(new Left(true): Xor[Boolean, Int])(_ < 13)
}

// Scalactic Or
@unifyRightToLeft
sealed abstract class Or[+G,+B]
final case class Good[+G](g: G) extends Or[G,Nothing]
final case class Bad[+B](b: B) extends Or[Nothing,B]

object TestOr {
def meh[F[_], A, B](fa: F[A])(f: A => B): F[B] = ???
meh(new Good(23): Or[Int, Boolean])(_ < 13)
meh(new Bad(true): Or[Int, Boolean])(_ < 13)
}

0 comments on commit ca31b36

Please sign in to comment.