Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,15 @@ newlines {

spaces {
afterKeywordBeforeParen = true
// afterSymbolicDefs = true
afterSymbolicDefs = true
inImportCurlyBraces = true
}

//verticalMultiline {
// atDefnSite = true
// arityThreshold = 4
// newlineAfterOpenParen = true
// newlineAfterImplicitKW = true
// newlineBeforeImplicitKW = false
//}

rewrite.rules = [
AsciiSortImports,
AvoidInfix,
PreferCurlyFors,
RedundantBraces,
RedundantParens,
SortModifiers
]
]
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ lazy val root =
(project in file("."))
.settings(
name := "scalaz-parsers",
scalacOptions ++= Seq("-Xsource:2.13"),
resolvers += "Sonatype OSS Staging".at(
"https://oss.sonatype.org/content/repositories/staging"
),
libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-zio" % "0.2.9",
"org.scalaz" %% "scalaz-base" % "96627337-SNAPSHOT",
"org.scalaz" %% "scalaz-base" % "e5ebff0a-SNAPSHOT",
"org.specs2" %% "specs2-core" % "4.3.5" % Test
)
)
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/scalaz/parsers/Iso.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scalaz.parsers

import scalaz.data.~>
import scalaz.tc._

trait Iso[F[_], G[_], A, B] { self =>
Expand Down Expand Up @@ -42,11 +43,11 @@ object Combinators {
override def from: UGV[B, A] = (b: B) => AG.or(ab.from(b), abOther.from(b))
}

// def unary_~(implicit GF: G ~> F, FG: F ~> G): Iso[F, G, B, A] =
// new Iso[F, G, B, A] {
// override def to: UFV[B, A] = (b: B) => GF.apply(ab.from(b))
// override def from: UGV[A, B] = (a: A) => FG.apply(ab.to(a))
// }
def unary_~(implicit FG: F ~> G, GF: G ~> F): Iso[F, G, B, A] =
new Iso[F, G, B, A] {
override def to: UFV[B, A] = b => GF.apply(ab.from(b))
override def from: UGV[A, B] = a => FG.apply(ab.to(a))
}

def ⓧ [A2, B2](
other: Iso[F, G, A2, B2]
Expand Down
26 changes: 26 additions & 0 deletions src/test/scala/scalaz/parsers/IsoOpsSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package scalaz.parsers

import org.specs2.mutable.Specification
import scalaz.Scalaz.Id
import scalaz.data.{ ~>, ∀ }
import scalaz.parsers.Combinators._

class IsoOpsSpec extends Specification {

private type TIso[A, B] = Iso[Id, Id, A, B]

private val iso = new TIso[Int, String] {
override def to: UFV[Int, String] = _.toString
override def from: UGV[String, Int] = _.toInt
}

implicit private val id: Id ~> Id = ∀.mk[Id ~> Id].from(identity)

"Transforming Iso" >> {
"via reverse" in {
iso.to(1) must_=== (~iso).from(1)
iso.from("1") must_=== (~iso).to("1")
iso.to(1) must_=== (~(~iso)).to(1)
}
}
}