All Versions
10
Latest Version
Avg Release Cycle
53 days
Latest Release
1043 days ago

Changelog History

  • v0.3.1

    July 19, 2019
  • v0.3.0

    April 13, 2019
  • v0.3.0-M4

    October 11, 2018
  • v0.3.0-M3

    October 11, 2018
  • v0.3.0-M2

    September 13, 2018
  • v0.3.0-M1 Changes

    September 09, 2018

    Available on Maven Central:

    addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0-M1")
    

    0๏ธโƒฃ A new feature comes to better-monadic-for, enabled by the flag -P:bm4:implicit-patterns (also enabled by default). This introduces a new keyword, implicit0, which can appear inside patterns, including those in for comprehensions:

    case class ImplicitTest(id: String) for { x \<- Option(42) implicit0(it) \<- Option(ImplicitTest("eggs")) \_ \<- Option("dummy") \_ = "dummy" \_ = assert(implicitly[ImplicitTest] eq it) } yield "ok"
    

    This also works in regular match clauses:

    (1, "foo", ImplicitTest("eggs")) match { case (\_, "foo", implicit0(it)) =\> assert(implicitly[ImplicitTest] eq it) }
    

    ๐Ÿ‘ The main goal is to support effectfully-created tagless algebras, but possibilities are large, so if you find a creative use for it, poke me on twitter (oleg.pyzhcov) or gitter to share!

    Current limitations

    ๐Ÿš€ As of this release, only simple named patterns can be used in implicit definition. That means, implicit0(x) will work, but not implicit0(x, y), implicit0(Some(x)), implicit0(_) or implicit0(x: ImplicitTest). The idea is to keep it as close as possible to a simple implicit val definition, so the latter restriction is the only one that's temporary.

    ๐Ÿ”Œ This also obviously doesn't play nice with IDEs. I will be looking into making an Intellij plugin, but no promises. In the meantime, you can use a stub extractor:

    object implicit0 { def unapply[A](a: A): Option[A] = Some(a) }
    
  • v0.2.2

    April 25, 2018
  • v0.2.1

    April 22, 2018
  • v0.2.0

    April 17, 2018
  • v0.1.0

    March 31, 2018