diff options
author | Jon Pretty <jon.pretty@propensive.com> | 2017-05-25 11:26:28 -0600 |
---|---|---|
committer | Jon Pretty <jon.pretty@propensive.com> | 2017-05-25 11:26:28 -0600 |
commit | 17cfdb350fa38454a76ed5370ac6f36c3a532d3e (patch) | |
tree | 56ab2e93523f870687ad1bf9dedcb2a4ada920c0 /examples/src/main | |
parent | 134cd5e20030e558dfb75e07f5e3eb3211680e0c (diff) | |
download | magnolia-17cfdb350fa38454a76ed5370ac6f36c3a532d3e.tar.gz magnolia-17cfdb350fa38454a76ed5370ac6f36c3a532d3e.tar.bz2 magnolia-17cfdb350fa38454a76ed5370ac6f36c3a532d3e.zip |
Progress with mutual recursion
Diffstat (limited to 'examples/src/main')
-rw-r--r-- | examples/src/main/scala/example.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/src/main/scala/example.scala b/examples/src/main/scala/example.scala index 7e9d80b..a031fbe 100644 --- a/examples/src/main/scala/example.scala +++ b/examples/src/main/scala/example.scala @@ -15,8 +15,14 @@ object Extractor extends Extractor_1 { implicit val intExtractor: Extractor[Int] = Extractor(_.toInt) implicit val stringExtractor: Extractor[String] = Extractor(identity) implicit val doubleExtractor: Extractor[Double] = Extractor(_.toDouble) + } -trait Extractor_1 { +trait Extractor_1 extends Extractor_2 { + implicit def listExtractor[T: Extractor]: Extractor[List[T]] = new Extractor[List[T]] { + def extract(source: String): List[T] = List(implicitly[Extractor[T]].extract(source)) + } +} +trait Extractor_2 { implicit def generic[T]: Extractor[T] = macro Macros.generic[T, Extractor[_]] } |