Skip to content

Commit

Permalink
feat: Support for ciris (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
rparree authored Sep 30, 2023
1 parent de20278 commit 07460a7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
25 changes: 23 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object docs extends BaseModule {

def artifactName = "iron-docs"

val modules: Seq[ScalaModule] = Seq(main, cats, circe, jsoniter, scalacheck, zio, zioJson)
val modules: Seq[ScalaModule] = Seq(main, cats, circe, ciris, jsoniter, scalacheck, zio, zioJson)

def docSources = T.sources {
T.traverse(modules)(_.docSources)().flatten
Expand Down Expand Up @@ -294,6 +294,27 @@ object circe extends SubModule {
object native extends NativeCrossModule
}

object ciris extends SubModule {

def artifactName = "iron-ciris"

def ivyDeps = Agg(
ivy"is.cir::ciris::3.1.0"
)

object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1",
ivy"is.cir::ciris::3.1.0"
)
}

object js extends JSCrossModule

object native extends NativeCrossModule

}

object zio extends SubModule {

def artifactName = "iron-zio"
Expand Down Expand Up @@ -362,4 +383,4 @@ object scalacheck extends SubModule {
object js extends JSCrossModule

object test extends Tests
}
}
11 changes: 11 additions & 0 deletions ciris/src/io.github.iltotore.iron/ciris.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.iltotore.iron

import _root_.ciris.ConfigDecoder
import cats.Show


object ciris:

inline given [T,A,B](using inline decoder: ConfigDecoder[T,A], inline constraint: _root_.io.github.iltotore.iron.Constraint[A, B], inline show: Show[A]): ConfigDecoder[T, A :| B] =
decoder.mapOption("")(_.refineOption)

19 changes: 19 additions & 0 deletions ciris/test/src/io/github/iltotore/iron/CirisSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.iltotore.iron

import _root_.ciris.ConfigDecoder
import utest.*
import ciris.given


object CirisSuite extends TestSuite:
val tests: Tests = Tests {

test("summon String => Int :| Pure") {
summon[ ConfigDecoder[String, Int :| Pure]]
}

test("summon from Int => Int :| Pure") {
summon[ConfigDecoder[Int, Int :| Pure]]
}
}

0 comments on commit 07460a7

Please sign in to comment.